mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06: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
|
|
@ -14,51 +14,24 @@ impl Content for TransportToolbar<Tui> {
|
|||
}
|
||||
}
|
||||
|
||||
impl Widget for TransportPlayPauseButton<Tui> {
|
||||
impl Content for TransportPlayPauseButton<Tui> {
|
||||
type Engine = Tui;
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
area.expect_min(10, 1)?;
|
||||
Ok(Some([area.x(), area.y(), 10, 1]))
|
||||
}
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let Self { value, focused, .. } = &self;
|
||||
Layers([
|
||||
&focused.then_some(CORNERS),
|
||||
&Inset::W(1, Styled(match value {
|
||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||
Layers2::new(|add|{
|
||||
//add(&self.focused.then_some(CORNERS))?;
|
||||
add(&Styled(match self.value {
|
||||
Some(TransportState::Stopped) => Some(GRAY_DIM.bold()),
|
||||
Some(TransportState::Starting) => Some(GRAY_NOT_DIM_BOLD),
|
||||
Some(TransportState::Rolling) => Some(WHITE_NOT_DIM_BOLD),
|
||||
_ => unreachable!(),
|
||||
}, match value {
|
||||
}, match self.value {
|
||||
Some(TransportState::Rolling) => "▶ PLAYING",
|
||||
Some(TransportState::Starting) => "READY ...",
|
||||
Some(TransportState::Stopped) => "⏹ STOPPED",
|
||||
_ => unreachable!(),
|
||||
}))
|
||||
]).render(to)
|
||||
//let area = to.area();
|
||||
//let [x, y, ..] = area;
|
||||
//let Self { value, focused } = &self;
|
||||
//let style = Some(match value {
|
||||
//Some(TransportState::Stopped) => GRAY_DIM.bold(),
|
||||
//Some(TransportState::Starting) => GRAY_NOT_DIM_BOLD,
|
||||
//Some(TransportState::Rolling) => WHITE_NOT_DIM_BOLD,
|
||||
//_ => unreachable!(),
|
||||
//});
|
||||
//let label = match value {
|
||||
//Some(TransportState::Rolling) => "▶ PLAYING",
|
||||
//Some(TransportState::Starting) => "READY ...",
|
||||
//Some(TransportState::Stopped) => "⏹ STOPPED",
|
||||
//_ => unreachable!(),
|
||||
//};
|
||||
//let area = to.blit(&label, x + 1, y, style)?.unwrap();
|
||||
//let area = [area.x(), area.y(), area.w() + 1, area.h() + 1];
|
||||
//if *focused {
|
||||
//let area = [area.x() - 1, area.y(), area.w() - 1, area.h() ];
|
||||
//CORNERS.draw(to)?;
|
||||
//to.fill_bg(area, COLOR_BG1);
|
||||
//}
|
||||
//Ok(Some(area))
|
||||
}))?;
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue