mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-24 23:23:58 +00:00
LibGUI: Fix view column auto-sizing of icon-only columns
For icon columns, just use the item height as the auto width for now. This gives us 16x16 icons, which is always what we want anyway.
This commit is contained in:
parent
248f2d5cf5
commit
ff98f55b85
Notes:
sideshowbarker
2024-07-19 06:16:30 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/ff98f55b853
1 changed files with 5 additions and 3 deletions
|
@ -71,15 +71,17 @@ void AbstractTableView::update_column_sizes()
|
|||
if (is_column_hidden(column))
|
||||
continue;
|
||||
int header_width = header_font().width(model.column_name(column));
|
||||
if (column == key_column)
|
||||
if (column == key_column && model.is_column_sortable(column))
|
||||
header_width += font().width(" \xE2\xAC\x86"); // UPWARDS BLACK ARROW
|
||||
int column_width = header_width;
|
||||
for (int row = 0; row < row_count; ++row) {
|
||||
auto cell_data = model.data(model.index(row, column));
|
||||
int cell_width = 0;
|
||||
if (cell_data.is_bitmap()) {
|
||||
if (cell_data.is_icon()) {
|
||||
cell_width = item_height();
|
||||
} else if (cell_data.is_bitmap()) {
|
||||
cell_width = cell_data.as_bitmap().width();
|
||||
} else {
|
||||
} else if (cell_data.is_valid()) {
|
||||
cell_width = font().width(cell_data.to_string());
|
||||
}
|
||||
column_width = max(column_width, cell_width);
|
||||
|
|
Loading…
Reference in a new issue