fix layout overflow of Stack component

This commit is contained in:
🪞👃🪞 2024-10-06 06:52:03 +03:00
parent c24f9a9eb5
commit 39edaea47c
3 changed files with 31 additions and 37 deletions

View file

@ -799,9 +799,7 @@ where
},
Direction::Right => {
(self.0)(&mut |component| {
if w >= to.w() {
return Ok(())
}
if w >= to.w() { return Ok(()) }
let size = component.push_x(w).max_x(to.w() - w).layout(to)?;
if let Some([width, height]) = size.map(|size|size.wh()) {
w = w + width.into();
@ -821,30 +819,26 @@ where
match self.1 {
Direction::Down => {
(self.0)(&mut |component| {
if h >= area.h() {
return Ok(())
}
let size = component.push_y(h).max_y(area.h() - h).layout(area.wh().into())?;
if h >= area.h() { return Ok(()) }
let item = component.push_y(h).max_y(area.h() - h);
let size = item.layout(area.wh().into())?;
if let Some([width, height]) = size.map(|size|size.wh()) {
Push::Y(h, component as &dyn Widget<Engine = E>).render(to)?;
item.render(to)?;
h = h + height;
if width > w {
w = width
}
if width > w { w = width }
};
Ok(())
})?;
},
Direction::Right => {
(self.0)(&mut |component| {
if w >= area.w() {
return Ok(())
}
let size = component.push_x(w).max_x(area.w() - w).layout(area.wh().into())?;
if w >= area.w() { return Ok(()) }
let item = component.push_x(w).max_x(area.w() - w);
let size = item.layout(area.wh().into())?;
if let Some([width, height]) = size.map(|size|size.wh()) {
Push::X(w, component as &dyn Widget<Engine = E>).render(to)?;
item.render(to)?;
w = width + w;
h = h.max(height)
if height > h { h = height }
};
Ok(())
})?;