Skip to content

Commit

Permalink
Merge #88
Browse files Browse the repository at this point in the history
  • Loading branch information
elbaro committed Dec 27, 2021
2 parents e6a19dd + 7733026 commit af671c3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/algo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ impl Forest {
min_size: child_style.min_size.resolve(node_inner_size),
max_size: child_style.max_size.resolve(node_inner_size),

position: child_style.position.map(|p| p.resolve(node_inner_size.width)),
position: child_style.position.zip_size(node_inner_size, |p, s| p.resolve(s)),
margin: child_style.margin.map(|m| m.resolve(node_inner_size.width).or_else(0.0)),
padding: child_style.padding.map(|p| p.resolve(node_inner_size.width).or_else(0.0)),
border: child_style.border.map(|b| b.resolve(node_inner_size.width).or_else(0.0)),
Expand Down
12 changes: 12 additions & 0 deletions src/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ impl<T> Rect<T> {
{
Rect { start: f(self.start), end: f(self.end), top: f(self.top), bottom: f(self.bottom) }
}
pub(crate) fn zip_size<R, F, U>(self, size: Size<U>, f: F) -> Rect<R>
where
F: Fn(T, U) -> R,
U: Copy,
{
Rect {
start: f(self.start, size.width),
end: f(self.end, size.width),
top: f(self.top, size.height),
bottom: f(self.bottom, size.height),
}
}
}

impl<T> Rect<T>
Expand Down

0 comments on commit af671c3

Please sign in to comment.