Fix cells_per_row calculation in grid widget
This commit is contained in:
parent
b89e78cd82
commit
504d9c2959
1 changed files with 3 additions and 2 deletions
|
|
@ -181,8 +181,9 @@ where
|
||||||
let available = limits.max();
|
let available = limits.max();
|
||||||
|
|
||||||
let cells_per_row = match self.columns {
|
let cells_per_row = match self.columns {
|
||||||
Constraint::MaxWidth(pixels) => (available.width
|
// width = n * (cell + spacing) - spacing, given n > 0
|
||||||
/ (pixels.0 + self.spacing / 2.0))
|
Constraint::MaxWidth(pixels) => ((available.width + self.spacing)
|
||||||
|
/ (pixels.0 + self.spacing))
|
||||||
.ceil() as usize,
|
.ceil() as usize,
|
||||||
Constraint::Amount(amount) => amount,
|
Constraint::Amount(amount) => amount,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue