Skip to content

Commit

Permalink
fix: Properly adjust accumulate sizes when using padding
Browse files Browse the repository at this point in the history
  • Loading branch information
marc2332 committed Sep 18, 2024
1 parent 732e03b commit 4d30b46
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions crates/torin/src/measure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ where

let mut inner_sizes = Size2D::default();

inner_sizes.width += node.padding.horizontal();
inner_sizes.height += node.padding.vertical();

if measure_inner_children && phase_measure_inner_children {
// Create an area containing the available space inside the inner area
let mut available_area = inner_area;
Expand Down Expand Up @@ -621,7 +624,7 @@ where
available_area.origin.x = child_area.max_x() + spacing.get();
available_area.size.width -= child_area.size.width + spacing.get();

inner_sizes.height = child_area.height().max(inner_sizes.height);
inner_sizes.height = (child_area.height() + parent_node.padding.vertical()).max(inner_sizes.height);
inner_sizes.width += child_area.width() + spacing.get();

// Keep the biggest height
Expand All @@ -647,7 +650,7 @@ where
available_area.origin.y = child_area.max_y() + spacing.get();
available_area.size.height -= child_area.size.height + spacing.get();

inner_sizes.width = child_area.width().max(inner_sizes.width);
inner_sizes.width = (child_area.width() + parent_node.padding.horizontal()).max(inner_sizes.width);
inner_sizes.height += child_area.height() + spacing.get();

// Keep the biggest width
Expand Down

0 comments on commit 4d30b46

Please sign in to comment.