LibGUI: Move selection behavior from TableView up to AbstractView

Let's make SelectionBehavior a view concept where views can either
select individual items (row, index) or whole rows. Maybe some day
we'll do whole columns, but I don't think we need that now.
This commit is contained in:
Andreas Kling 2020-12-17 00:49:42 +01:00
parent c8fb00fe4d
commit f0138fcb25
Notes: sideshowbarker 2024-07-19 00:47:08 +09:00
5 changed files with 13 additions and 15 deletions

View file

@ -149,13 +149,13 @@ void TableView::paint_event(PaintEvent& event)
if (m_grid_style == GridStyle::Vertical || m_grid_style == GridStyle::Both)
painter.draw_line(cell_rect_for_fill.top_right(), cell_rect_for_fill.bottom_right(), palette().ruler());
if (m_cursor_style == CursorStyle::Item && cell_index == cursor_index())
if (selection_behavior() == SelectionBehavior::SelectItems && cell_index == cursor_index())
painter.draw_rect(cell_rect_for_fill, palette().text_cursor());
x += column_width + horizontal_padding() * 2;
}
if (is_focused() && cursor_style() == CursorStyle::Row && row_index == cursor_index().row()) {
if (is_focused() && selection_behavior() == SelectionBehavior::SelectRows && row_index == cursor_index().row()) {
painter.draw_rect(row_rect, widget_background_color);
painter.draw_focus_rect(row_rect, palette().focus_outline());
}
@ -244,12 +244,4 @@ void TableView::set_grid_style(GridStyle style)
update();
}
void TableView::set_cursor_style(CursorStyle style)
{
if (m_cursor_style == style)
return;
m_cursor_style = style;
update();
}
}