Pārlūkot izejas kodu

GTableView: Tweak the look of column headers.

Andreas Kling 6 gadi atpakaļ
vecāks
revīzija
7e955f7b60
1 mainītis faili ar 5 papildinājumiem un 6 dzēšanām
  1. 5 6
      LibGUI/GTableView.cpp

+ 5 - 6
LibGUI/GTableView.cpp

@@ -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);