From 56e80fafd6545e4ad646f68e760ea752534d4c82 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 27 Aug 2020 18:38:39 +0200 Subject: [PATCH] Spreadsheet: Draw cell cursor and selected cells differently Now that the table view has a cursor, we can distinguish it from the selected cells. Draw the cells with a nice variant of the selection color as background. --- Applications/Spreadsheet/SpreadsheetView.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Applications/Spreadsheet/SpreadsheetView.cpp b/Applications/Spreadsheet/SpreadsheetView.cpp index e84c6c3775..10c3fff6f8 100644 --- a/Applications/Spreadsheet/SpreadsheetView.cpp +++ b/Applications/Spreadsheet/SpreadsheetView.cpp @@ -123,9 +123,16 @@ void SpreadsheetView::TableCellPainter::paint(GUI::Painter& painter, const Gfx:: { // Draw a border. // Undo the horizontal padding done by the table view... - painter.draw_rect(rect.inflated(m_table_view.horizontal_padding() * 2, 0), palette.ruler()); - if (m_table_view.selection().contains(index)) - painter.draw_rect(rect.inflated(m_table_view.horizontal_padding() * 2 + 1, 1), palette.ruler_border()); + auto cell_rect = rect.inflated(m_table_view.horizontal_padding() * 2, 0); + + painter.draw_rect(cell_rect, palette.ruler()); + if (m_table_view.selection().contains(index)) { + Color fill_color = palette.selection(); + fill_color.set_alpha(80); + painter.fill_rect(cell_rect, fill_color); + } + if (m_table_view.cursor_index() == index) + painter.draw_rect(cell_rect, palette.text_cursor()); auto text_color = index.data(GUI::ModelRole::ForegroundColor).to_color(palette.color(m_table_view.foreground_role())); auto data = index.data();