mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 14:28:49 +00:00
LibGUI: Make AbstractTableView and TableView more customisable
This patchset adds a few getters/setters to AbstractTableView to make its looks more customisable: - Header width & text alignment - Default column width - Ability to disable selected row highlighting
This commit is contained in:
parent
697faba147
commit
e1a819827c
Notes:
sideshowbarker
2024-07-19 03:13:16 +09:00
Author: https://github.com/alimpfard
Commit: e1a819827c
Pull-request: https://github.com/SerenityOS/serenity/pull/3279
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/linusg
3 changed files with 31 additions and 5 deletions
|
@ -165,7 +165,7 @@ void AbstractTableView::paint_headers(Painter& painter)
|
|||
auto text_rect = cell_rect.translated(horizontal_padding(), 0);
|
||||
if (pressed)
|
||||
text_rect.move_by(1, 1);
|
||||
painter.draw_text(text_rect, text, header_font(), Gfx::TextAlignment::CenterLeft, palette().button_text());
|
||||
painter.draw_text(text_rect, text, header_font(), column_header_alignment(column_index), palette().button_text());
|
||||
x_offset += column_width + horizontal_padding() * 2;
|
||||
}
|
||||
}
|
||||
|
@ -249,6 +249,23 @@ int AbstractTableView::column_width(int column_index) const
|
|||
return column_data(column_index).width;
|
||||
}
|
||||
|
||||
void AbstractTableView::set_column_width(int column, int width)
|
||||
{
|
||||
column_data(column).width = width;
|
||||
}
|
||||
|
||||
Gfx::TextAlignment AbstractTableView::column_header_alignment(int column_index) const
|
||||
{
|
||||
if (!model())
|
||||
return Gfx::TextAlignment::CenterLeft;
|
||||
return column_data(column_index).header_alignment;
|
||||
}
|
||||
|
||||
void AbstractTableView::set_column_header_alignment(int column, Gfx::TextAlignment alignment)
|
||||
{
|
||||
column_data(column).header_alignment = alignment;
|
||||
}
|
||||
|
||||
void AbstractTableView::mousemove_event(MouseEvent& event)
|
||||
{
|
||||
if (!model())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue