Fix width column factor computation in table

This commit is contained in:
Héctor Ramón Jiménez 2025-07-16 21:39:40 +02:00
parent 6e71c7dd6f
commit a3d42e2d37
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -250,11 +250,10 @@ where
}
}
let width_factor =
width.fill_factor().max(size.width.fill_factor());
let width_factor = width.fill_factor();
let height_factor = size.height.fill_factor();
if width_factor != 0 || height_factor != 0 {
if width_factor != 0 || height_factor != 0 || size.width.is_fill() {
column_factors[column] =
column_factors[column].max(width_factor);
@ -332,56 +331,57 @@ where
}
}
if width_factor != 0
|| size.width.fill_factor() != 0
|| size.height.fill_factor() != 0
if width_factor == 0
&& size.width.fill_factor() == 0
&& size.height.fill_factor() == 0
{
let row_factor = row_factors[row];
let max_width = if width_factor == 0 {
if size.width.is_fill() {
metrics.columns[column]
} else {
(available.width - x).max(0.0)
}
} else {
width_unit * width_factor as f32
};
let max_height = if row_factor == 0 {
if size.height.is_fill() {
metrics.rows[row]
} else {
(available.height - y).max(0.0)
}
} else {
height_unit * row_factor as f32
};
let limits = layout::Limits::new(
Size::ZERO,
Size::new(max_width, max_height),
)
.width(width);
let layout = cell.as_widget().layout(state, renderer, &limits);
let size = limits.resolve(
if let Length::Fixed(_) = width {
width
} else {
table_fluid
},
Length::Shrink,
layout.size(),
);
metrics.columns[column] =
metrics.columns[column].max(size.width);
metrics.rows[row] = metrics.rows[row].max(size.height);
cells[i] = layout;
y += size.height + spacing_y;
continue;
}
let row_factor = row_factors[row];
let max_width = if width_factor == 0 {
if size.width.is_fill() {
metrics.columns[column]
} else {
(available.width - x).max(0.0)
}
} else {
width_unit * width_factor as f32
};
let max_height = if row_factor == 0 {
if size.height.is_fill() {
metrics.rows[row]
} else {
(available.height - y).max(0.0)
}
} else {
height_unit * row_factor as f32
};
let limits = layout::Limits::new(
Size::ZERO,
Size::new(max_width, max_height),
)
.width(width);
let layout = cell.as_widget().layout(state, renderer, &limits);
let size = limits.resolve(
if let Length::Fixed(_) = width {
width
} else {
table_fluid
},
Length::Shrink,
layout.size(),
);
metrics.columns[column] = metrics.columns[column].max(size.width);
metrics.rows[row] = metrics.rows[row].max(size.height);
cells[i] = layout;
y += size.height + spacing_y;
}
// THIRD PASS