mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 23:09:08 +00:00
LibGUI: Support bitmaps in GTableView cells.
Use this to add an icon for each process in the ProcessManager. Right now they all use a generic gear icon, but I'd like to have per-process icons, obviously. :^)
This commit is contained in:
parent
3fe7ddadaf
commit
b132150799
Notes:
sideshowbarker
2024-07-19 15:35:12 +09:00
Author: https://github.com/awesomekling
Commit: b132150799
4 changed files with 30 additions and 13 deletions
|
@ -121,7 +121,11 @@ void GTableView::paint_event(GPaintEvent& event)
|
|||
auto column_metadata = m_model->column_metadata(column_index);
|
||||
int column_width = column_metadata.preferred_width;
|
||||
Rect cell_rect(horizontal_padding() + x_offset, y, column_width, item_height());
|
||||
painter.draw_text(cell_rect, m_model->data(row_index, column_index).to_string(), column_metadata.text_alignment, text_color);
|
||||
auto data = m_model->data(row_index, column_index);
|
||||
if (data.is_bitmap())
|
||||
painter.blit(cell_rect.location(), data.as_bitmap(), data.as_bitmap().rect());
|
||||
else
|
||||
painter.draw_text(cell_rect, data.to_string(), column_metadata.text_alignment, text_color);
|
||||
x_offset += column_width + horizontal_padding() * 2;
|
||||
}
|
||||
++painted_item_index;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue