summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI
diff options
context:
space:
mode:
authorthankyouverycool <66646555+thankyouverycool@users.noreply.github.com>2021-03-03 23:39:56 -0500
committerAndreas Kling <kling@serenityos.org>2021-03-04 16:28:12 +0100
commitaf581cbd91185aabd2f4c054d00a0bcb0a26e460 (patch)
tree50c7d4c1cdc481e0532a2e7e97e492a82935704e /Userland/Libraries/LibGUI
parent2871df6f0d131f4777847665d9cbc0ca93e3e752 (diff)
downloadserenity-af581cbd91185aabd2f4c054d00a0bcb0a26e460.zip
LibGUI: Increase row height in Table/ColumnViews and center icons
16x16 icons are now guaranteed at least 1px margins between rows
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r--Userland/Libraries/LibGUI/AbstractTableView.cpp4
-rw-r--r--Userland/Libraries/LibGUI/AbstractTableView.h1
-rw-r--r--Userland/Libraries/LibGUI/ColumnsView.h2
-rw-r--r--Userland/Libraries/LibGUI/TableView.cpp1
4 files changed, 5 insertions, 3 deletions
diff --git a/Userland/Libraries/LibGUI/AbstractTableView.cpp b/Userland/Libraries/LibGUI/AbstractTableView.cpp
index c0b8b2a6d3..69e5c13458 100644
--- a/Userland/Libraries/LibGUI/AbstractTableView.cpp
+++ b/Userland/Libraries/LibGUI/AbstractTableView.cpp
@@ -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();
}
}
diff --git a/Userland/Libraries/LibGUI/AbstractTableView.h b/Userland/Libraries/LibGUI/AbstractTableView.h
index b64e4b3bcb..f20eee617c 100644
--- a/Userland/Libraries/LibGUI/AbstractTableView.h
+++ b/Userland/Libraries/LibGUI/AbstractTableView.h
@@ -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;
diff --git a/Userland/Libraries/LibGUI/ColumnsView.h b/Userland/Libraries/LibGUI/ColumnsView.h
index 843b3d2e6c..523a7c2cef 100644
--- a/Userland/Libraries/LibGUI/ColumnsView.h
+++ b/Userland/Libraries/LibGUI/ColumnsView.h
@@ -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; }
diff --git a/Userland/Libraries/LibGUI/TableView.cpp b/Userland/Libraries/LibGUI/TableView.cpp
index 2f48f466b9..2946eb601b 100644
--- a/Userland/Libraries/LibGUI/TableView.cpp
+++ b/Userland/Libraries/LibGUI/TableView.cpp
@@ -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); });