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

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

View file

@ -56,11 +56,11 @@ pub enum LaunchMode {
/// 🎧 Multi-track MIDI sequencer.
Arranger {
/// 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
#[arg(short = 'x', long, default_value_t = 4)] tracks: usize,
#[arg(short = 'x', long, default_value_t = 12)] tracks: usize,
/// 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
Mixer,

View file

@ -129,6 +129,22 @@ impl ArrangementCommand {
todo!("delegate");
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> {
let index = arranger.scene_add(None, None)?.0;
*arranger.selection_mut() = match arranger.selection() {

View file

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