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

@ -16,18 +16,18 @@ impl Demo<Tui> {
Self {
index: 0,
items: vec![
Box::new(tek_sequencer::TransportPlayPauseButton {
_engine: Default::default(),
transport: None,
value: Some(TransportState::Stopped),
focused: true
}),
Box::new(tek_sequencer::TransportPlayPauseButton {
_engine: Default::default(),
transport: None,
value: Some(TransportState::Rolling),
focused: false
}),
//Box::new(tek_sequencer::TransportPlayPauseButton {
//_engine: Default::default(),
//transport: None,
//value: Some(TransportState::Stopped),
//focused: true
//}),
//Box::new(tek_sequencer::TransportPlayPauseButton {
//_engine: Default::default(),
//transport: None,
//value: Some(TransportState::Rolling),
//focused: false
//}),
]
}
}
@ -48,24 +48,24 @@ impl Content for Demo<Tui> {
add(&Border(Square(border_style)))?;
add(&Outset::XY(2, 1, "..."))?;
Ok(())
}))?;
}).debug())?;
add(&Layers::new(|add|{
add(&Background(Color::Rgb(128,64,0)))?;
add(&Border(Lozenge(border_style)))?;
add(&Outset::XY(4, 2, "---"))?;
Ok(())
}))?;
}).debug())?;
add(&Layers::new(|add|{
add(&Background(Color::Rgb(96,64,0)))?;
add(&Border(SquareBold(border_style)))?;
add(&Outset::XY(6, 3, "~~~"))?;
Ok(())
}))?;
}).debug())?;
Ok(())
})))?;
})).debug())?;
Ok(())

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(())
})?;

View file

@ -16,9 +16,9 @@ impl Content for Arranger<Tui> {
add(&arrangement.split(
direction,
20,
self.phrases.clone().debug()
.split(direction.ccw(), 20, sequencer.debug())
.min_y(20)).debug())
self.phrases.clone()
.split(direction.ccw(), 20, sequencer)
.min_y(20)).fill_y())
} else {
add(&self.arrangement)
}
@ -29,7 +29,7 @@ impl Content for Arranger<Tui> {
//add(modal as &dyn Widget<Engine = Tui>)?;
}
Ok(())
}).debug()
})
}
}