align command buttons

This commit is contained in:
🪞👃🪞 2025-05-17 18:33:51 +03:00
parent 29b2789be6
commit aeb1f7a9e0
5 changed files with 52 additions and 38 deletions

View file

@ -24,7 +24,7 @@
(bsp/s (bsp/s
:view-status-h2 :view-status-h2
(bsp/n (fill/x (align/w :view-tracks-inputs)) (bsp/n (fill/x (align/w :view-tracks-inputs))
(bsp/n (fill/x (align/w :view-tracks-devices)) (bsp/s (fill/x (align/w :view-tracks-names))
(bsp/s (fill/x (align/w :view-tracks-outputs)) (bsp/s (fill/x (align/w :view-tracks-outputs))
(bsp/s (fill/x (align/w :view-tracks-tracks)) (bsp/s (fill/x (align/w :view-tracks-devices))
:view-tracks-scenes))))))))) :view-tracks-scenes)))))))))

View file

@ -118,13 +118,13 @@ impl App {
Fixed::y(2, self.project.view_track_inputs(self.color)) Fixed::y(2, self.project.view_track_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(3, self.project.view_track_outputs(self.color)) Fixed::y(1 + self.project.midi_outs.len() as u16, self.project.view_track_outputs(self.color, self.midi_outs().len().min(24) as u16))
} }
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(3, self.project.view_track_devices(self.color)) Fixed::y(3, self.project.view_track_devices(self.color))
} }
pub fn view_tracks_tracks <'a> (&'a self) -> impl Content<TuiOut> + use<'a> { pub fn view_tracks_names <'a> (&'a self) -> impl Content<TuiOut> + use<'a> {
Fixed::y(1, self.project.view_track_names(self.color)) Fixed::y(2, self.project.view_track_names(self.color))
} }
pub fn view_pool (&self) -> impl Content<TuiOut> + use<'_> { pub fn view_pool (&self) -> impl Content<TuiOut> + use<'_> {
Fixed::x(20, Bsp::s( Fixed::x(20, Bsp::s(

View file

@ -56,11 +56,11 @@ pub enum LaunchMode {
/// 🎧 Multi-track MIDI sequencer. /// 🎧 Multi-track MIDI sequencer.
Arranger { Arranger {
/// Number of scenes /// Number of scenes
#[arg(short = 'y', long, default_value_t = 8)] scenes: usize, #[arg(short = 'y', long, default_value_t = 16)] scenes: usize,
/// Number of tracks /// Number of tracks
#[arg(short = 'x', long, default_value_t = 4)] tracks: usize, #[arg(short = 'x', long, default_value_t = 12)] tracks: usize,
/// Width of tracks /// Width of tracks
#[arg(short = 'w', long, default_value_t = 14)] track_width: usize, #[arg(short = 'w', long, default_value_t = 15)] track_width: usize,
}, },
/// TODO: A MIDI-controlled audio mixer /// TODO: A MIDI-controlled audio mixer
Mixer, Mixer,

View file

@ -129,6 +129,22 @@ impl ArrangementCommand {
todo!("delegate"); todo!("delegate");
Ok(None) Ok(None)
} }
fn output_add (arranger: &mut Arrangement) -> Perhaps<Self> {
arranger.midi_outs.push(JackMidiOut::new(
arranger.jack(),
format!("/M{}", arranger.midi_outs.len() + 1),
&[]
)?);
Ok(None)
}
fn input_add (arranger: &mut Arrangement) -> Perhaps<Self> {
arranger.midi_ins.push(JackMidiIn::new(
arranger.jack(),
format!("M{}/", arranger.midi_ins.len() + 1),
&[]
)?);
Ok(None)
}
fn scene_add (arranger: &mut Arrangement) -> Perhaps<Self> { fn scene_add (arranger: &mut Arrangement) -> Perhaps<Self> {
let index = arranger.scene_add(None, None)?.0; let index = arranger.scene_add(None, None)?.0;
*arranger.selection_mut() = match arranger.selection() { *arranger.selection_mut() = match arranger.selection() {

View file

@ -55,9 +55,9 @@ pub trait TracksView:
content: impl Content<TuiOut> content: impl Content<TuiOut>
) -> impl Content<TuiOut> { ) -> impl Content<TuiOut> {
Bsp::w( Bsp::w(
Fixed::x(4, button_add), Fill::y(Fixed::x(4, Align::nw(button_add))),
Bsp::e( Bsp::e(
Fixed::x(20, Align::w(button)), Fixed::x(20, Fill::y(Align::nw(button))),
Fill::xy(Align::c(content)) Fill::xy(Align::c(content))
) )
) )
@ -72,7 +72,7 @@ pub trait TracksView:
theme, theme,
button_2("t", "rack", false), button_2("t", "rack", false),
button_2("T", "+", false), button_2("T", "+", false),
Tui::bg(theme.darker.rgb, Fixed::y(1, Fill::x( Tui::bg(theme.darker.rgb, Fixed::y(2, 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),
@ -80,39 +80,37 @@ pub trait TracksView:
track.color.light.rgb track.color.light.rgb
} else { } else {
track.color.base.rgb track.color.base.rgb
}, Align::nw(Bsp::e( }, Bsp::s(Fill::x(Align::nw(Bsp::e(
format!("·t{index:02} "), format!("·t{index:02} "),
Tui::fg(Rgb(255, 255, 255), Tui::bold(true, &track.name)) Tui::fg(Rgb(255, 255, 255), Tui::bold(true, &track.name))
))))); ))), Tui::bg(if self.selection().track() == Some(index) {
track.color.light.rgb
} else {
track.color.base.rgb
}, Fill::x(Align::w(format!("·mute ·solo"))))))));
} }
}))))) })))))
} }
fn view_track_outputs <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> { fn view_track_outputs <'a> (&'a self, theme: ItemTheme, h: u16) -> impl Content<TuiOut> {
let mut h = 0u16; self.view_track_row_section(theme,
for track in self.tracks().iter() { Bsp::s(
h = h.max(track.sequencer.midi_outs.len() as u16); Fill::x(Align::w(button_2("o", "utput", false))),
} Fill::xy(Stack::south(|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
self.view_track_row_section( for port in self.midi_outs().iter() {
theme, add(&Push::x(2, Fill::x(Align::w(port.name()))));
button_2("o", "utput", false), }
}))),
button_2("O", "+", false), button_2("O", "+", false),
Align::w(Fixed::y(1 + h*2, 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), Align::nw(Fill::y(Map::south(1, ||track.sequencer.midi_outs.iter(),
Align::nw(Bsp::n( |port, index|Tui::fg(Rgb(255, 255, 255),
Tui::bg(if self.selection().track() == Some(index) { Fixed::y(1, Tui::bg(track.color.dark.rgb, Fill::x(Align::w(
track.color.light.rgb format!("·o{index:02} {}", port.name())))))))))));
} else { }
track.color.base.rgb })))))
}, Fill::x(Align::w(format!("·mute ·solo")))),
Map::south(2, ||track.sequencer.midi_outs.iter(),
|port, index|Tui::fg(Rgb(255, 255, 255),
Fixed::y(2, Tui::bg(track.color.dark.rgb, Fill::x(Align::w(
format!("·o{index:02} {}", port.name())))))))))));
}
})))))))
} }
fn view_track_devices <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> { fn view_track_devices <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> {
let mut h = 2u16; let mut h = 2u16;