mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 12:46:42 +01:00
fix layout overflow of Stack component
This commit is contained in:
parent
c24f9a9eb5
commit
39edaea47c
3 changed files with 31 additions and 37 deletions
|
|
@ -16,18 +16,18 @@ impl Demo<Tui> {
|
||||||
Self {
|
Self {
|
||||||
index: 0,
|
index: 0,
|
||||||
items: vec![
|
items: vec![
|
||||||
Box::new(tek_sequencer::TransportPlayPauseButton {
|
//Box::new(tek_sequencer::TransportPlayPauseButton {
|
||||||
_engine: Default::default(),
|
//_engine: Default::default(),
|
||||||
transport: None,
|
//transport: None,
|
||||||
value: Some(TransportState::Stopped),
|
//value: Some(TransportState::Stopped),
|
||||||
focused: true
|
//focused: true
|
||||||
}),
|
//}),
|
||||||
Box::new(tek_sequencer::TransportPlayPauseButton {
|
//Box::new(tek_sequencer::TransportPlayPauseButton {
|
||||||
_engine: Default::default(),
|
//_engine: Default::default(),
|
||||||
transport: None,
|
//transport: None,
|
||||||
value: Some(TransportState::Rolling),
|
//value: Some(TransportState::Rolling),
|
||||||
focused: false
|
//focused: false
|
||||||
}),
|
//}),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -48,24 +48,24 @@ impl Content for Demo<Tui> {
|
||||||
add(&Border(Square(border_style)))?;
|
add(&Border(Square(border_style)))?;
|
||||||
add(&Outset::XY(2, 1, "..."))?;
|
add(&Outset::XY(2, 1, "..."))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}))?;
|
}).debug())?;
|
||||||
|
|
||||||
add(&Layers::new(|add|{
|
add(&Layers::new(|add|{
|
||||||
add(&Background(Color::Rgb(128,64,0)))?;
|
add(&Background(Color::Rgb(128,64,0)))?;
|
||||||
add(&Border(Lozenge(border_style)))?;
|
add(&Border(Lozenge(border_style)))?;
|
||||||
add(&Outset::XY(4, 2, "---"))?;
|
add(&Outset::XY(4, 2, "---"))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}))?;
|
}).debug())?;
|
||||||
|
|
||||||
add(&Layers::new(|add|{
|
add(&Layers::new(|add|{
|
||||||
add(&Background(Color::Rgb(96,64,0)))?;
|
add(&Background(Color::Rgb(96,64,0)))?;
|
||||||
add(&Border(SquareBold(border_style)))?;
|
add(&Border(SquareBold(border_style)))?;
|
||||||
add(&Outset::XY(6, 3, "~~~"))?;
|
add(&Outset::XY(6, 3, "~~~"))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}))?;
|
}).debug())?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})))?;
|
})).debug())?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -799,9 +799,7 @@ where
|
||||||
},
|
},
|
||||||
Direction::Right => {
|
Direction::Right => {
|
||||||
(self.0)(&mut |component| {
|
(self.0)(&mut |component| {
|
||||||
if w >= to.w() {
|
if w >= to.w() { return Ok(()) }
|
||||||
return Ok(())
|
|
||||||
}
|
|
||||||
let size = component.push_x(w).max_x(to.w() - w).layout(to)?;
|
let size = component.push_x(w).max_x(to.w() - w).layout(to)?;
|
||||||
if let Some([width, height]) = size.map(|size|size.wh()) {
|
if let Some([width, height]) = size.map(|size|size.wh()) {
|
||||||
w = w + width.into();
|
w = w + width.into();
|
||||||
|
|
@ -821,30 +819,26 @@ where
|
||||||
match self.1 {
|
match self.1 {
|
||||||
Direction::Down => {
|
Direction::Down => {
|
||||||
(self.0)(&mut |component| {
|
(self.0)(&mut |component| {
|
||||||
if h >= area.h() {
|
if h >= area.h() { return Ok(()) }
|
||||||
return Ok(())
|
let item = component.push_y(h).max_y(area.h() - h);
|
||||||
}
|
let size = item.layout(area.wh().into())?;
|
||||||
let size = component.push_y(h).max_y(area.h() - h).layout(area.wh().into())?;
|
|
||||||
if let Some([width, height]) = size.map(|size|size.wh()) {
|
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;
|
h = h + height;
|
||||||
if width > w {
|
if width > w { w = width }
|
||||||
w = width
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
},
|
},
|
||||||
Direction::Right => {
|
Direction::Right => {
|
||||||
(self.0)(&mut |component| {
|
(self.0)(&mut |component| {
|
||||||
if w >= area.w() {
|
if w >= area.w() { return Ok(()) }
|
||||||
return Ok(())
|
let item = component.push_x(w).max_x(area.w() - w);
|
||||||
}
|
let size = item.layout(area.wh().into())?;
|
||||||
let size = component.push_x(w).max_x(area.w() - w).layout(area.wh().into())?;
|
|
||||||
if let Some([width, height]) = size.map(|size|size.wh()) {
|
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;
|
w = width + w;
|
||||||
h = h.max(height)
|
if height > h { h = height }
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@ impl Content for Arranger<Tui> {
|
||||||
add(&arrangement.split(
|
add(&arrangement.split(
|
||||||
direction,
|
direction,
|
||||||
20,
|
20,
|
||||||
self.phrases.clone().debug()
|
self.phrases.clone()
|
||||||
.split(direction.ccw(), 20, sequencer.debug())
|
.split(direction.ccw(), 20, sequencer)
|
||||||
.min_y(20)).debug())
|
.min_y(20)).fill_y())
|
||||||
} else {
|
} else {
|
||||||
add(&self.arrangement)
|
add(&self.arrangement)
|
||||||
}
|
}
|
||||||
|
|
@ -29,7 +29,7 @@ impl Content for Arranger<Tui> {
|
||||||
//add(modal as &dyn Widget<Engine = Tui>)?;
|
//add(modal as &dyn Widget<Engine = Tui>)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}).debug()
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue