mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 04:22:45 +00:00 
			
		
		
		
	Spreadsheet: Let GUI::TableView paint the grid and cursor :^)
This commit is contained in:
		
							parent
							
								
									2222fc5e08
								
							
						
					
					
						commit
						ccea1b2376
					
				
					 1 changed files with 2 additions and 5 deletions
				
			
		|  | @ -57,6 +57,8 @@ SpreadsheetView::SpreadsheetView(Sheet& sheet) | ||||||
| { | { | ||||||
|     set_layout<GUI::VerticalBoxLayout>().set_margins({ 2, 2, 2, 2 }); |     set_layout<GUI::VerticalBoxLayout>().set_margins({ 2, 2, 2, 2 }); | ||||||
|     m_table_view = add<GUI::TableView>(); |     m_table_view = add<GUI::TableView>(); | ||||||
|  |     m_table_view->set_grid_style(GUI::TableView::GridStyle::Both); | ||||||
|  |     m_table_view->set_cursor_style(GUI::TableView::CursorStyle::Item); | ||||||
|     m_table_view->row_header().set_visible(true); |     m_table_view->row_header().set_visible(true); | ||||||
|     m_table_view->set_model(SheetModel::create(*m_sheet)); |     m_table_view->set_model(SheetModel::create(*m_sheet)); | ||||||
| 
 | 
 | ||||||
|  | @ -125,16 +127,11 @@ void SpreadsheetView::TableCellPainter::paint(GUI::Painter& painter, const Gfx:: | ||||||
|     // Undo the horizontal padding done by the table view...
 |     // Undo the horizontal padding done by the table view...
 | ||||||
|     auto cell_rect = rect.inflated(m_table_view.horizontal_padding() * 2, 0); |     auto cell_rect = rect.inflated(m_table_view.horizontal_padding() * 2, 0); | ||||||
| 
 | 
 | ||||||
|     painter.draw_line(cell_rect.bottom_left(), cell_rect.bottom_right(), palette.ruler()); |  | ||||||
|     painter.draw_line(cell_rect.top_right(), cell_rect.bottom_right(), palette.ruler()); |  | ||||||
| 
 |  | ||||||
|     if (m_table_view.selection().contains(index)) { |     if (m_table_view.selection().contains(index)) { | ||||||
|         Color fill_color = palette.selection(); |         Color fill_color = palette.selection(); | ||||||
|         fill_color.set_alpha(80); |         fill_color.set_alpha(80); | ||||||
|         painter.fill_rect(cell_rect, fill_color); |         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 text_color = index.data(GUI::ModelRole::ForegroundColor).to_color(palette.color(m_table_view.foreground_role())); | ||||||
|     auto data = index.data(); |     auto data = index.data(); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling