From 3a65e9107e3e34e0b067240771b9fe38b5651d6e Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 11 Apr 2020 18:56:15 +0200 Subject: [PATCH] LibGUI: Respect Model::Role::BackgroundColor This implementation is very gappy, but the basic feature allows us to highlight cells with a custom background color. --- Libraries/LibGUI/TableView.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Libraries/LibGUI/TableView.cpp b/Libraries/LibGUI/TableView.cpp index 30204b6087..7578730564 100644 --- a/Libraries/LibGUI/TableView.cpp +++ b/Libraries/LibGUI/TableView.cpp @@ -131,6 +131,11 @@ void TableView::paint_event(PaintEvent& event) text_color = is_focused() ? palette().selection_text() : palette().inactive_selection_text(); else text_color = model()->data(cell_index, Model::Role::ForegroundColor).to_color(palette().color(foreground_role())); + 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.draw_text(cell_rect, data.to_string(), font, column_metadata.text_alignment, text_color, Gfx::TextElision::Right); } }