use stack in view_inputs

This commit is contained in:
🪞👃🪞 2025-05-17 23:05:29 +03:00
parent 50c263b4d3
commit 958e602577
3 changed files with 61 additions and 49 deletions

View file

@ -64,7 +64,7 @@ arranger-ext:
arranger-release: arranger-release:
{{release}} {{name}} {{bpm}} arranger {{release}} {{name}} {{bpm}} arranger
arranger-release-ext: arranger-release-ext:
{{release}} {{name}} {{bpm}} {{midi-in}} {{midi-out}} arranger {{release}} {{name}} {{bpm}} {{midi-in}} {{firefox-in}} {{midi-out}} arranger
groovebox: groovebox:
{{debug}} {{name}} {{bpm}} groovebox {{debug}} {{name}} {{bpm}} groovebox

View file

@ -127,11 +127,10 @@ impl App {
self.project.view_inputs(self.color)) self.project.view_inputs(self.color))
} }
pub fn view_tracks_outputs <'a> (&'a self) -> impl Content<TuiOut> + use<'a> { pub fn view_tracks_outputs <'a> (&'a self) -> impl Content<TuiOut> + use<'a> {
Fixed::y(1 + self.project.midi_outs.len() as u16, self.project.view_outputs(self.color)
self.project.view_outputs(self.color))
} }
pub fn view_tracks_devices <'a> (&'a self) -> impl Content<TuiOut> + use<'a> { pub fn view_tracks_devices <'a> (&'a self) -> impl Content<TuiOut> + use<'a> {
Fixed::y(2, self.project.view_track_devices(self.color)) Fixed::y(4, self.project.view_track_devices(self.color))
} }
pub fn view_tracks_names <'a> (&'a self) -> impl Content<TuiOut> + use<'a> { pub fn view_tracks_names <'a> (&'a self) -> impl Content<TuiOut> + use<'a> {
Fixed::y(2, self.project.view_track_names(self.color)) Fixed::y(2, self.project.view_track_names(self.color))

View file

@ -7,78 +7,91 @@ impl Arrangement {
h = h.max(self.midi_ins.len() as u16); h = h.max(self.midi_ins.len() as u16);
} }
let h = h + 1; let h = h + 1;
let list = Fixed::x(20, Fill::y(Stack::south(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{ Stack::south(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
add(&Fixed::y(1, Align::w( add(&Fixed::y(1,
button_3("i", "nput ", format!("{}", self.midi_ins.len()), false)))); Bsp::e(Fixed::x(20, Align::w(button_3("i", "nput ", format!("{}", self.midi_ins.len()), false))),
for (index, port) in self.midi_ins.iter().enumerate() { Bsp::w(Fixed::x(4, button_2("I", "+", false)),
add(&Fixed::y(1, Fill::x(Align::w(format!("·i{index:02} {}", port.name()))))); Stack::east(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
} for (index, track, x1, x2) in self.tracks_with_sizes() {
}))); add(&Align::w(row!(
self.view_track_row_section(theme, list, button_2("I", "+", false), Either(track.sequencer.monitoring, Tui::fg(Green, "mon "), "mon "),
Tui::bg(theme.darker.rgb, Align::w(Fill::x( Either(track.sequencer.recording, Tui::fg(Red, "rec "), "rec "),
Stack::east(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{ Either(track.sequencer.overdub, Tui::fg(Yellow, "dub "), "dub "),
for (index, track, x1, x2) in self.tracks_with_sizes() { )))
add(&Fixed::x(self.track_width(index, track), }
Stack::south(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{ })))));
let index = 0; for (index, port) in self.midi_ins().iter().enumerate() {
add(&Fixed::y(1, track.sequencer.midi_ins.get(0).map(|port| add(&Fixed::y(1,
Tui::fg_bg(Rgb(255, 255, 255), track.color.base.rgb, Bsp::e(Fixed::x(20, Align::w(format!(" ● i{index:02} {}", port.name()))),
Fill::x(Align::w(format!("·i{index:02} {}", port.name()))))))); Bsp::w(Fixed::x(4, ()),
for (index, port) in self.midi_ins().iter().enumerate() { Stack::east(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
add(&Fixed::y(1, Align::w(row!( for (index, track, x1, x2) in self.tracks_with_sizes() {
Either(track.sequencer.monitoring, Tui::fg(Green, "●mon "), "·mon "), add(&Align::w(row!(
Either(track.sequencer.recording, Tui::fg(Red, "●rec "), "·rec "), Either(track.sequencer.monitoring, Tui::fg(Green, ""), " · "),
Either(track.sequencer.overdub, Tui::fg(Yellow, "●dub "), "·dub "), Either(track.sequencer.recording, Tui::fg(Red, ""), " · "),
)))); Either(track.sequencer.overdub, Tui::fg(Yellow, ""), " · "),
)))
} }
})))}}))))) })))));
}
})
} }
pub fn view_outputs <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> + 'a { pub fn view_outputs <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> + 'a {
let mut h = 1u16; let mut h = 1;
for track in self.tracks().iter() { for output in self.midi_outs().iter() {
h = h.max(track.sequencer.midi_outs.len() as u16); h += 1 + output.conn().len();
} }
let h = h + 1; let h = h as u16;
let list = Bsp::s( let list = Bsp::s(
Fixed::y(1, Fill::x(Align::w(button_3("o", "utput", format!("{}", self.midi_outs.len()), false)))), Fixed::y(1, Fill::x(Align::w(button_3("o", "utput", format!("{}", self.midi_outs.len()), false)))),
Fixed::y(h - 1, Fill::xy(Align::nw(Stack::south(|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{ Fixed::y(h - 1, Fill::xy(Align::nw(Stack::south(|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
for (index, port) in self.midi_outs().iter().enumerate() { for (index, port) in self.midi_outs().iter().enumerate() {
add(&Fill::x(Align::w(format!("·o{index:02} {}", port.name())))); add(&Fixed::y(1,Fill::x(Bsp::e(
Align::w(Bsp::e(format!(" ● o{index:02} "), Tui::fg(Rgb(255,255,255),Tui::bold(true, port.name())))),
Fill::x(Align::e(format!("{}/{} ",
port.port().get_connections().len(),
port.conn().len())))))));
for (index, conn) in port.conn().iter().enumerate() {
add(&Fixed::y(1, Fill::x(Align::w(format!(" c{index:02}{}", conn.info())))));
}
} }
}))))); })))));
self.view_track_row_section(theme, list, button_2("O", "+", false), Fixed::y(h, self.view_track_row_section(theme, list, button_2("O", "+", false),
Tui::bg(theme.darker.rgb, Align::w(Fill::x( Tui::bg(theme.darker.rgb, Align::w(Fill::x(
Stack::east(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{ Stack::east(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
for (index, track, x1, x2) in self.tracks_with_sizes() { for (index, track, x1, x2) in self.tracks_with_sizes() {
add(&Fixed::x(self.track_width(index, track), add(&Fixed::x(self.track_width(index, track),
Stack::south(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{ Stack::south(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
let index = 0; let index = 0;
add(&Fixed::y(1, track.sequencer.midi_outs.get(0).map(|port| add(&Fixed::y(1, Align::w(Bsp::e(
Tui::fg_bg(Rgb(255, 255, 255), track.color.base.rgb, Either(true, Tui::fg(Green, "play "), "play "),
Fill::x(Align::w(format!("·o{index:02} {}", port.name()))))))); Either(false, Tui::fg(Yellow, "solo "), "solo "),
))));
for (index, port) in self.midi_outs().iter().enumerate() { for (index, port) in self.midi_outs().iter().enumerate() {
add(&Fixed::y(1, Align::w(Bsp::e( add(&Fixed::y(1, Align::w(Bsp::e(
Either(true, Tui::fg(Green, "●play "), "·play "), Either(true, Tui::fg(Green, ""), " · "),
Either(false, Tui::fg(Yellow, "●solo "), "·solo "), Either(false, Tui::fg(Yellow, ""), " · "),
)))); ))));
} for (index, conn) in port.conn().iter().enumerate() {
})))}}))))) add(&Fixed::y(1, Fill::x("")));
}
}})))}}))))))
} }
pub fn view_track_devices <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> + 'a { pub fn view_track_devices <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> + 'a {
let mut h = 2u16; let mut h = 2u16;
for track in self.tracks().iter() { for track in self.tracks().iter() {
h = h.max(track.devices.len() as u16); h = h.max(track.devices.len() as u16 * 2);
} }
self.view_track_row_section( self.view_track_row_section(
theme, theme,
button_3("d", "evice", format!("{}", self.track().map(|t|t.devices.len()).unwrap_or(0)), false), button_3("d", "evice", format!("{}", self.track().map(|t|t.devices.len()).unwrap_or(0)), false),
button_2("D", "+", false), button_2("D", "+", false),
Stack::east(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{ Stack::east(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
for (index, track, x1, x2) in self.tracks_with_sizes() { for (index, track, x1, x2) in self.tracks_with_sizes() {
add(&Fixed::xy(self.track_width(index, track), h + 1, add(&Fixed::xy(self.track_width(index, track), h + 1,
Tui::bg(track.color.dark.rgb, Align::nw(Map::south(1, move||0..h, Tui::bg(track.color.dark.rgb, Align::nw(Map::south(2, move||0..h,
|_, index|format!("·d{index:02} {}", "--------")))))); |_, index|Fixed::xy(track.width as u16, 2, Tui::bg(ItemTheme::G[32].base.rgb,
Align::nw(format!(" · {}", "--")))))))));
} }
})) }))
} }
@ -129,7 +142,7 @@ pub trait TracksView:
theme: ItemTheme, theme: ItemTheme,
button: impl Content<TuiOut>, button: impl Content<TuiOut>,
button_add: impl Content<TuiOut>, button_add: impl Content<TuiOut>,
content: impl Content<TuiOut> content: impl Content<TuiOut>
) -> impl Content<TuiOut> { ) -> impl Content<TuiOut> {
Bsp::w(Fill::y(Fixed::x(4, Align::nw(button_add))), Bsp::w(Fill::y(Fixed::x(4, Align::nw(button_add))),
Bsp::e(Fixed::x(20, Fill::y(Align::nw(button))), Fill::xy(Align::c(content)))) Bsp::e(Fixed::x(20, Fill::y(Align::nw(button))), Fill::xy(Align::c(content))))
@ -201,7 +214,7 @@ pub trait TracksView:
} }
self.view_track_row_section( self.view_track_row_section(
theme, theme,
button_2("i", "nput", false), button_2("i", "nput", false),
button_2("I", "+", false), button_2("I", "+", false),
Tui::bg(theme.darker.rgb, Align::w(Fill::x( Tui::bg(theme.darker.rgb, Align::w(Fill::x(
Stack::east(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{ Stack::east(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
@ -230,7 +243,7 @@ pub trait ScenesView:
HasSceneScroll + HasSceneScroll +
HasClipsSize + HasClipsSize +
Send + Send +
Sync Sync
{ {
/// Default scene height. /// Default scene height.
const H_SCENE: usize = 2; const H_SCENE: usize = 2;