Skip to content

Commit

Permalink
Fix the handling of Flex::gap (#560)
Browse files Browse the repository at this point in the history
Fixes #559

See comment on the fix for an explanation. Essentially, the `major`
value was used for multiple purposes, and this corrects into the
expected "direction".
  • Loading branch information
DJMcNab authored Aug 28, 2024
1 parent 923c0fb commit 251f42a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions masonry/src/widget/flex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,13 @@ impl Widget for Flex {
tracing::warn!("A child of Flex is flex, but Flex is unbounded.");
}

if !self.children.is_empty() {
// If we have at least one child, the last child added `gap` to `major`, which means that `major` is
// not the total size of the flex in the major axis, it's instead where the "next widget" will be placed.
// However, for the rest of this value, we need the total size of the widget in the major axis.
major -= gap;
}

if flex_sum > 0.0 {
major = total_major;
}
Expand Down

0 comments on commit 251f42a

Please sign in to comment.