mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 20:56:43 +01:00
handle transport focus in parent
This commit is contained in:
parent
5c8cb8e413
commit
d577449b72
1 changed files with 32 additions and 57 deletions
|
|
@ -155,27 +155,29 @@ impl<E: Engine> Audio for TransportToolbar<E> {
|
||||||
impl Handle<Tui> for TransportToolbar<Tui> {
|
impl Handle<Tui> for TransportToolbar<Tui> {
|
||||||
fn handle (&mut self, from: &TuiInput) -> Perhaps<bool> {
|
fn handle (&mut self, from: &TuiInput) -> Perhaps<bool> {
|
||||||
match from.event() {
|
match from.event() {
|
||||||
key!(KeyCode::Left) => {
|
key!(KeyCode::Left) => { self.focus_prev(); },
|
||||||
self.focus_prev();
|
key!(KeyCode::Right) => { self.focus_next(); },
|
||||||
Ok(Some(true))
|
_ => return self.focused_mut().handle(from)
|
||||||
},
|
|
||||||
key!(KeyCode::Right) => {
|
|
||||||
self.focus_next();
|
|
||||||
Ok(Some(true))
|
|
||||||
},
|
|
||||||
_ => self.focused_mut().handle(from)
|
|
||||||
}
|
}
|
||||||
|
Ok(Some(true))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Content for TransportToolbar<Tui> {
|
impl Content for TransportToolbar<Tui> {
|
||||||
type Engine = Tui;
|
type Engine = Tui;
|
||||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||||
Split::right(|add|{
|
Split::right(|add|{
|
||||||
add(&self.playing)?;
|
let focus_wrap = |focused, component|Layers::new(move |add|{
|
||||||
add(&self.bpm)?;
|
if focused {
|
||||||
add(&self.quant)?;
|
add(&CORNERS)?;
|
||||||
add(&self.sync)?;
|
add(&Background(COLOR_BG1))?;
|
||||||
add(&self.clock)?;
|
}
|
||||||
|
add(component)
|
||||||
|
});
|
||||||
|
add(&focus_wrap(self.focused && self.playing.focused, &self.playing))?;
|
||||||
|
add(&focus_wrap(self.focused && self.bpm.focused, &self.bpm))?;
|
||||||
|
add(&focus_wrap(self.focused && self.quant.focused, &self.quant))?;
|
||||||
|
add(&focus_wrap(self.focused && self.sync.focused, &self.sync))?;
|
||||||
|
add(&focus_wrap(self.focused && self.clock.focused, &self.clock))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -260,7 +262,6 @@ impl Content for TransportPlayPauseButton<Tui> {
|
||||||
type Engine = Tui;
|
type Engine = Tui;
|
||||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||||
Layers::new(|add|{
|
Layers::new(|add|{
|
||||||
add(&self.focused.then_some(CORNERS))?;
|
|
||||||
add(&Plus::X(1, Min::Y(2, Styled(match self.value {
|
add(&Plus::X(1, Min::Y(2, Styled(match self.value {
|
||||||
Some(TransportState::Stopped) => Some(GRAY_DIM.bold()),
|
Some(TransportState::Stopped) => Some(GRAY_DIM.bold()),
|
||||||
Some(TransportState::Starting) => Some(GRAY_NOT_DIM_BOLD),
|
Some(TransportState::Starting) => Some(GRAY_NOT_DIM_BOLD),
|
||||||
|
|
@ -307,18 +308,11 @@ impl Handle<Tui> for TransportBPM<Tui> {
|
||||||
impl Content for TransportBPM<Tui> {
|
impl Content for TransportBPM<Tui> {
|
||||||
type Engine = Tui;
|
type Engine = Tui;
|
||||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||||
let Self { value, focused, .. } = self;
|
let Self { value, .. } = self;
|
||||||
Layers::new(move|add|{
|
Outset::X(1u16, Split::down(move |add|{
|
||||||
add(&Outset::X(1u16, Split::down(|add|{
|
|
||||||
add(&"BPM")?;
|
add(&"BPM")?;
|
||||||
add(&format!("{}.{:03}", *value as usize, (value * 1000.0) % 1000.0).as_str())
|
add(&format!("{}.{:03}", *value as usize, (value * 1000.0) % 1000.0).as_str())
|
||||||
})))?;
|
}))
|
||||||
if *focused {
|
|
||||||
add(&CORNERS)?;
|
|
||||||
add(&Background(COLOR_BG1))?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -355,18 +349,11 @@ impl Handle<Tui> for TransportQuantize<Tui> {
|
||||||
impl Content for TransportQuantize<Tui> {
|
impl Content for TransportQuantize<Tui> {
|
||||||
type Engine = Tui;
|
type Engine = Tui;
|
||||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||||
let Self { value, focused, .. } = self;
|
let Self { value, .. } = self;
|
||||||
Layers::new(move|add|{
|
Outset::X(1u16, Split::down(|add|{
|
||||||
add(&Outset::X(1u16, Split::down(|add|{
|
|
||||||
add(&"QUANT")?;
|
add(&"QUANT")?;
|
||||||
add(&ppq_to_name(*value as usize))
|
add(&ppq_to_name(*value as usize))
|
||||||
})))?;
|
}))
|
||||||
if *focused {
|
|
||||||
add(&CORNERS)?;
|
|
||||||
add(&Background(COLOR_BG1))?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -403,18 +390,11 @@ impl Handle<Tui> for TransportSync<Tui> {
|
||||||
impl Content for TransportSync<Tui> {
|
impl Content for TransportSync<Tui> {
|
||||||
type Engine = Tui;
|
type Engine = Tui;
|
||||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||||
let Self { value, focused, .. } = self;
|
let Self { value, .. } = self;
|
||||||
Layers::new(move|add|{
|
Outset::X(1u16, Split::down(|add|{
|
||||||
add(&Outset::X(1u16, Split::down(|add|{
|
|
||||||
add(&"SYNC")?;
|
add(&"SYNC")?;
|
||||||
add(&ppq_to_name(*value as usize))
|
add(&ppq_to_name(*value as usize))
|
||||||
})))?;
|
}))
|
||||||
if *focused {
|
|
||||||
add(&CORNERS)?;
|
|
||||||
add(&Background(COLOR_BG1))?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -453,12 +433,7 @@ impl Content for TransportClock<Tui> {
|
||||||
add(&Outset::X(1u16, Split::down(|add|{
|
add(&Outset::X(1u16, Split::down(|add|{
|
||||||
add(&format!("{bars}.{beats}.{pulses:02}").as_str())?;
|
add(&format!("{bars}.{beats}.{pulses:02}").as_str())?;
|
||||||
add(&format!("{minutes}:{seconds:02}:{msecs:03}").as_str())
|
add(&format!("{minutes}:{seconds:02}:{msecs:03}").as_str())
|
||||||
})))?;
|
})))
|
||||||
if *focused {
|
|
||||||
add(&CORNERS)?;
|
|
||||||
add(&Background(COLOR_BG1))?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue