1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 22:07:34 +00:00

LibGUI: Increase row height in Table/ColumnViews and center icons

16x16 icons are now guaranteed at least 1px margins between rows
This commit is contained in:
thankyouverycool 2021-03-03 23:39:56 -05:00 committed by Andreas Kling
parent 2871df6f0d
commit af581cbd91
4 changed files with 5 additions and 3 deletions

View file

@ -87,7 +87,7 @@ void AbstractTableView::update_column_sizes()
auto cell_data = model.index(row, column).data();
int cell_width = 0;
if (cell_data.is_icon()) {
cell_width = row_height();
cell_width = cell_data.as_icon().bitmap_for_size(16)->width();
} else if (cell_data.is_bitmap()) {
cell_width = cell_data.as_bitmap().width();
} else if (cell_data.is_valid()) {
@ -399,7 +399,7 @@ int AbstractTableView::horizontal_padding() const
int AbstractTableView::row_height() const
{
return font().glyph_height() + 6;
return font().glyph_height() + icon_padding();
}
}

View file

@ -60,6 +60,7 @@ public:
void set_column_painting_delegate(int column, OwnPtr<TableCellPaintingDelegate>);
int horizontal_padding() const;
int icon_padding() const { return 8; }
Gfx::IntPoint adjusted_position(const Gfx::IntPoint&) const;

View file

@ -46,7 +46,7 @@ private:
void push_column(const ModelIndex& parent_index);
void update_column_sizes();
int item_height() const { return 16; }
int item_height() const { return 18; }
int icon_size() const { return 16; }
int icon_spacing() const { return 2; }
int text_padding() const { return 2; }

View file

@ -125,6 +125,7 @@ void TableView::paint_event(PaintEvent& event)
painter.blit(cell_rect.location(), data.as_bitmap(), data.as_bitmap().rect());
} else if (data.is_icon()) {
if (auto bitmap = data.as_icon().bitmap_for_size(16)) {
cell_rect.set_y(cell_rect.y() + (row_height() - bitmap->height()) / 2);
if (is_selected_row) {
auto tint = selection_color.with_alpha(100);
painter.blit_filtered(cell_rect.location(), *bitmap, bitmap->rect(), [&](auto src) { return src.blend(tint); });