mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
arranger: layout track headers with Stack
This commit is contained in:
parent
a7f37e52cf
commit
0d9bb709a5
2 changed files with 65 additions and 48 deletions
|
|
@ -201,75 +201,92 @@ pub trait TracksView: HasSize<TuiOut> + HasTrackScroll + HasSelection + HasMidiI
|
|||
.then_some((t, track, x1, x2)))
|
||||
}
|
||||
fn view_track_names (&self, theme: ItemTheme) -> impl Content<TuiOut> {
|
||||
let mut max_outputs = 0u16;
|
||||
for track in self.tracks().iter() {
|
||||
max_outputs = max_outputs.max(track.sequencer.midi_outs.len() as u16);
|
||||
}
|
||||
Bsp::w(
|
||||
Fixed::x(20, Tui::bg(theme.darkest.rgb,
|
||||
col!(Tui::bold(true, "[t]rack"), "[T] Add"))),
|
||||
Align::w(Fixed::y(max_outputs + 1, Tui::bg(theme.darker.rgb,
|
||||
Align::w(Fill::x(Map::new(
|
||||
||self.tracks_with_sizes(&self.selection(), None).skip(self.track_scroll()),
|
||||
move|(index, track, x1, x2): (usize, &Track, usize, usize), _|
|
||||
Push::x(index as u16 * 14, Fixed::xy(track.width as u16, max_outputs + 1,
|
||||
Tui::bg(track.color.dark.rgb, Align::nw(Bsp::s(Tui::fg(
|
||||
Rgb(255, 255, 255),
|
||||
Tui::bold(true, format!("{}", track.name))
|
||||
), format!("{index} {x1} {x2}")))))))))))))
|
||||
let header = Fixed::x(20, Tui::bg(theme.darkest.rgb,
|
||||
row!(Tui::bold(true, "[t]rack"), "[T] add")));
|
||||
let content = Fixed::y(1, Align::w(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(&self.selection(), None)
|
||||
.skip(self.track_scroll())
|
||||
{
|
||||
(add)(&Fixed::x(track.width as u16,
|
||||
Tui::bg(track.color.dark.rgb, Align::nw(Tui::fg(
|
||||
Rgb(255, 255, 255), Tui::bold(true,
|
||||
format!("{}", track.name)))))));
|
||||
}
|
||||
}))))));
|
||||
Bsp::w(header, content)
|
||||
}
|
||||
fn view_track_outputs <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> {
|
||||
let mut max_outputs = 0u16;
|
||||
for track in self.tracks().iter() {
|
||||
max_outputs = max_outputs.max(track.sequencer.midi_outs.len() as u16);
|
||||
}
|
||||
Bsp::w(
|
||||
Fixed::x(20, Tui::bg(theme.darkest.rgb,
|
||||
col!(Tui::bold(true, "[o]utput"), "[O] Add"))),
|
||||
Align::w(Fixed::y(max_outputs + 1, Tui::bg(theme.darker.rgb, Align::w(Fill::x(Map::new(
|
||||
||self.tracks_with_sizes(&self.selection(), None).skip(self.track_scroll()),
|
||||
move|(index, track, x1, x2): (usize, &'a Track, usize, usize), _|
|
||||
Push::x(x2 as u16, Tui::bg(track.color.dark.rgb, Fixed::xy(
|
||||
track.width as u16,
|
||||
max_outputs + 1,
|
||||
Align::nw(Bsp::s(
|
||||
let header = Fixed::x(20, Tui::bg(theme.darkest.rgb,
|
||||
col!(Tui::bold(true, "[o]utput"), "[O] Add")));
|
||||
let content = Align::w(Fixed::y(max_outputs + 1,
|
||||
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(&self.selection(), None)
|
||||
.skip(self.track_scroll())
|
||||
{
|
||||
(add)(&Fixed::x(track.width as u16, Align::nw(Bsp::s(
|
||||
format!("[mut] [sol]"),
|
||||
Map::south(1, ||track.sequencer.midi_outs.iter(),
|
||||
|port, index|Tui::fg(Rgb(255, 255, 255),
|
||||
format!("{index}: {}", port.name())))))))))))))))
|
||||
format!("{index}: {}", port.name())))))));
|
||||
}
|
||||
}))))));
|
||||
Bsp::w(header, content)
|
||||
}
|
||||
fn view_track_inputs <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> {
|
||||
let mut max_inputs = 0u16;
|
||||
let mut h = 0u16;
|
||||
for track in self.tracks().iter() {
|
||||
max_inputs = max_inputs.max(track.sequencer.midi_ins.len() as u16);
|
||||
h = h.max(track.sequencer.midi_ins.len() as u16);
|
||||
}
|
||||
Bsp::w(
|
||||
Fixed::x(20, Tui::bg(theme.darkest.rgb,
|
||||
col!(Tui::bold(true, "[i]nputs"), "[I] Add"))),
|
||||
Fill::x(Align::w(Fixed::y(max_inputs + 1, Tui::bg(theme.darker.rgb, Align::w(Fill::x(Map::new(
|
||||
||self.tracks_with_sizes(&self.selection(), None).skip(self.track_scroll()),
|
||||
move|(index, track, x1, x2): (usize, &'a Track, usize, usize), _|
|
||||
Push::x(x2 as u16, Fixed::xy(track.width as u16, max_inputs + 1,
|
||||
let header = Tui::bg(theme.darkest.rgb, row!(Tui::bold(true, "[i]nputs"), "[I] Add"));
|
||||
let content = 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(&self.selection(), None)
|
||||
.skip(self.track_scroll())
|
||||
{
|
||||
add(&Fixed::xy(track.width as u16, h + 1,
|
||||
Tui::bg(track.color.dark.rgb, Align::nw(Bsp::s(
|
||||
format!("[rec] [mon]"),
|
||||
Map::south(1, ||track.sequencer.midi_ins.iter(),
|
||||
|port, index|Tui::fg(Rgb(255, 255, 255),
|
||||
format!("{index}: {}", port.name()))))))))))))))))
|
||||
format!("{index}: {}", port.name()))))))));
|
||||
}
|
||||
|
||||
}))));
|
||||
Bsp::w(
|
||||
Fixed::x(20, header),
|
||||
Fixed::y(h, Fill::x(Align::w(Fixed::y(h + 1, content)))),
|
||||
)
|
||||
}
|
||||
fn view_track_devices <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> {
|
||||
let mut max_devices = 2u16;
|
||||
let mut h = 2u16;
|
||||
for track in self.tracks().iter() {
|
||||
max_devices = max_devices.max(track.devices.len() as u16);
|
||||
h = h.max(track.devices.len() as u16);
|
||||
}
|
||||
let header = Tui::bg(theme.darkest.rgb, col!(Tui::bold(true, "[d]evice"), "[D] Add"));
|
||||
let content = 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(&self.selection(), None)
|
||||
.skip(self.track_scroll())
|
||||
{
|
||||
add(&Fixed::xy(track.width as u16, h + 1,
|
||||
Tui::bg(track.color.dark.rgb, Align::nw(Map::south(1, move||0..h,
|
||||
|_, index|format!("{index}: {}", "--------"))))));
|
||||
}
|
||||
}))));
|
||||
Bsp::w(
|
||||
Fixed::x(20, Tui::bg(theme.darkest.rgb,
|
||||
col!(Tui::bold(true, "[d]evice"), "[D] Add"))),
|
||||
Fixed::y(max_devices, Tui::bg(theme.darker.rgb, Align::w(Fill::x(Map::new(
|
||||
||self.tracks_with_sizes(&self.selection(), None).skip(self.track_scroll()),
|
||||
move|(index, track, x1, x2): (usize, &'a Track, usize, usize), _|
|
||||
Push::x(x2 as u16, Fixed::xy(track.width as u16, max_devices + 1,
|
||||
Tui::bg(track.color.dark.rgb, Align::nw(Map::south(1, move||0..max_devices,
|
||||
|_, index|format!("{index}: {}", "--------"))))))))))))
|
||||
Fixed::x(20, header),
|
||||
Fixed::y(h, content),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue