mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
wip: closure-based collections
This commit is contained in:
parent
4c23aed40a
commit
1cbf8de4e4
4 changed files with 72 additions and 56 deletions
|
|
@ -13,32 +13,33 @@ pub struct Demo<E: Engine> {
|
|||
|
||||
impl Demo<Tui> {
|
||||
fn new () -> Self {
|
||||
let mut items: Vec<Box<dyn Widget<Engine = Tui>>> = vec![];
|
||||
items.push(Box::new(tek_sequencer::TransportPlayPauseButton {
|
||||
_engine: Default::default(),
|
||||
value: Some(TransportState::Stopped),
|
||||
focused: true
|
||||
}));
|
||||
items.push(Box::new(tek_sequencer::TransportPlayPauseButton {
|
||||
_engine: Default::default(),
|
||||
value: Some(TransportState::Rolling),
|
||||
focused: false
|
||||
}));
|
||||
Self { index: 0, items }
|
||||
Self {
|
||||
index: 0,
|
||||
items: vec![
|
||||
Box::new(tek_sequencer::TransportPlayPauseButton {
|
||||
_engine: Default::default(),
|
||||
value: Some(TransportState::Stopped),
|
||||
focused: true
|
||||
}),
|
||||
Box::new(tek_sequencer::TransportPlayPauseButton {
|
||||
_engine: Default::default(),
|
||||
value: Some(TransportState::Rolling),
|
||||
focused: false
|
||||
}),
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Content for Demo<Tui> {
|
||||
type Engine = Tui;
|
||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||
Align::Center(Layers([
|
||||
&Outset::WH(2, 1, FillBg(Color::Rgb(0,128,128))),
|
||||
&self.items[self.index]
|
||||
//&Layers(&[
|
||||
//&"---------",
|
||||
//&Align::Center("...")
|
||||
//])
|
||||
]))
|
||||
Layers2::new(|add|{
|
||||
add(&Align::Center("FOOBAR"))?;
|
||||
add(&Align::Center("FOO"))?;
|
||||
Ok(())
|
||||
})
|
||||
//Align::Center(&self.items[self.index] as &dyn Widget<Engine = Tui>)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue