1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 20:15:07 +00:00

LibGUI: Implement searching/jumping as you type in views

This allows the user to start typing and highlighting and jumping
to a match in ColumnsView, IconView, TableView and TreeView if
the model supports it.
This commit is contained in:
Tom 2020-10-20 15:13:28 -06:00 committed by Andreas Kling
parent 307f0bc778
commit 52a847a0eb
13 changed files with 244 additions and 19 deletions

View file

@ -127,11 +127,6 @@ void TableView::paint_event(PaintEvent& event)
painter.blit(cell_rect.location(), *bitmap, bitmap->rect());
}
} else {
Color text_color;
if (is_selected_row)
text_color = is_focused() ? palette().selection_text() : palette().inactive_selection_text();
else
text_color = cell_index.data(ModelRole::ForegroundColor).to_color(palette().color(foreground_role()));
if (!is_selected_row) {
auto cell_background_color = cell_index.data(ModelRole::BackgroundColor);
if (cell_background_color.is_valid())
@ -139,7 +134,7 @@ void TableView::paint_event(PaintEvent& event)
}
auto text_alignment = cell_index.data(ModelRole::TextAlignment).to_text_alignment(Gfx::TextAlignment::CenterLeft);
painter.draw_text(cell_rect, data.to_string(), font_for_index(cell_index), text_alignment, text_color, Gfx::TextElision::Right);
draw_item_text(painter, cell_index, is_selected_row, cell_rect, data.to_string(), font_for_index(cell_index), text_alignment, Gfx::TextElision::Right);
}
}