mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
trim arranger view names
This commit is contained in:
parent
6be71a4413
commit
d806014df2
3 changed files with 39 additions and 34 deletions
|
|
@ -46,16 +46,16 @@ from_jack!(|jack| ArrangerTui {
|
|||
render!(<Tui>|self: ArrangerTui|{
|
||||
let arranger = ||lay!(|add|{
|
||||
let color = self.color;
|
||||
add(&Fill::wh(Tui::bg(color.darkest.rgb, "x")))?;
|
||||
add(&Fill::wh(Tui::bg(color.darkest.rgb, ())))?;
|
||||
add(&Fill::wh(Lozenge(Style::default().fg(color.light.rgb).bg(color.darker.rgb))))?;
|
||||
match self.mode {
|
||||
ArrangerMode::H => todo!("horizontal arranger"),
|
||||
ArrangerMode::V(factor) => add(&lay!(![
|
||||
ArrangerVColumnSeparator::from(self),
|
||||
ArrangerVRowSeparator::from((self, factor)),
|
||||
ArrangerVColSep::from(self),
|
||||
ArrangerVRowSep::from((self, factor)),
|
||||
col!(![
|
||||
ArrangerVHeader::from(self),
|
||||
ArrangerVContent::from((self, factor)),
|
||||
ArrangerVHead::from(self),
|
||||
ArrangerVBody::from((self, factor)),
|
||||
]),
|
||||
ArrangerVCursor::from((self, factor)),
|
||||
])),
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
use crate::*;
|
||||
|
||||
pub struct ArrangerVColumnSeparator {
|
||||
pub struct ArrangerVColSep {
|
||||
cols: Vec<(usize, usize)>,
|
||||
scenes_w: u16,
|
||||
sep_fg: Color,
|
||||
}
|
||||
|
||||
impl From<&ArrangerTui> for ArrangerVColumnSeparator {
|
||||
impl From<&ArrangerTui> for ArrangerVColSep {
|
||||
fn from (state: &ArrangerTui) -> Self {
|
||||
Self {
|
||||
cols: track_widths(state.tracks()),
|
||||
|
|
@ -16,7 +16,7 @@ impl From<&ArrangerTui> for ArrangerVColumnSeparator {
|
|||
}
|
||||
}
|
||||
|
||||
render!(<Tui>|self: ArrangerVColumnSeparator|render(move|to: &mut TuiOutput|{
|
||||
render!(<Tui>|self: ArrangerVColSep|render(move|to: &mut TuiOutput|{
|
||||
let style = Some(Style::default().fg(self.sep_fg));
|
||||
Ok(for x in self.cols.iter().map(|col|col.1) {
|
||||
let x = self.scenes_w + to.area().x() + x as u16;
|
||||
|
|
@ -26,12 +26,12 @@ render!(<Tui>|self: ArrangerVColumnSeparator|render(move|to: &mut TuiOutput|{
|
|||
})
|
||||
}));
|
||||
|
||||
pub struct ArrangerVRowSeparator {
|
||||
pub struct ArrangerVRowSep {
|
||||
rows: Vec<(usize, usize)>,
|
||||
sep_fg: Color,
|
||||
}
|
||||
|
||||
impl From<(&ArrangerTui, usize)> for ArrangerVRowSeparator {
|
||||
impl From<(&ArrangerTui, usize)> for ArrangerVRowSep {
|
||||
fn from ((state, factor): (&ArrangerTui, usize)) -> Self {
|
||||
Self {
|
||||
rows: ArrangerScene::ppqs(state.scenes(), factor),
|
||||
|
|
@ -40,7 +40,7 @@ impl From<(&ArrangerTui, usize)> for ArrangerVRowSeparator {
|
|||
}
|
||||
}
|
||||
|
||||
render!(<Tui>|self: ArrangerVRowSeparator|render(move|to: &mut TuiOutput|{
|
||||
render!(<Tui>|self: ArrangerVRowSep|render(move|to: &mut TuiOutput|{
|
||||
Ok(for y in self.rows.iter().map(|row|row.1) {
|
||||
let y = to.area().y() + (y / PPQ) as u16 + 1;
|
||||
if y >= to.buffer.area.height { break }
|
||||
|
|
@ -135,7 +135,7 @@ render!(<Tui>|self: ArrangerVCursor|render(move|to: &mut TuiOutput|{
|
|||
})
|
||||
}));
|
||||
|
||||
pub struct ArrangerVHeader<'a> {
|
||||
pub struct ArrangerVHead<'a> {
|
||||
tracks: &'a Vec<ArrangerTrack>,
|
||||
cols: Vec<(usize, usize)>,
|
||||
focused: bool,
|
||||
|
|
@ -146,7 +146,7 @@ pub struct ArrangerVHeader<'a> {
|
|||
current: &'a Arc<Moment>,
|
||||
}
|
||||
|
||||
impl<'a> From<&'a ArrangerTui> for ArrangerVHeader<'a> {
|
||||
impl<'a> From<&'a ArrangerTui> for ArrangerVHead<'a> {
|
||||
fn from (state: &'a ArrangerTui) -> Self {
|
||||
Self {
|
||||
tracks: &state.tracks,
|
||||
|
|
@ -161,12 +161,20 @@ impl<'a> From<&'a ArrangerTui> for ArrangerVHeader<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
render!(<Tui>|self: ArrangerVHeader<'a>|row!(
|
||||
render!(<Tui>|self: ArrangerVHead<'a>|row!(
|
||||
(track, w) in self.tracks.iter().zip(self.cols.iter().map(|col|col.0)) => {
|
||||
|
||||
// name and width of track
|
||||
let name = track.name().read().unwrap();
|
||||
let max_w = w.saturating_sub(1).min(name.len()).max(2);
|
||||
let name = Tui::bold(true, Tui::fg(track.color.lightest.rgb, format!("▎{}", &name[0..max_w])));
|
||||
let name = track.name().read().unwrap();
|
||||
let max_w = w.saturating_sub(1).min(name.len()).max(2);
|
||||
let name = Tui::bold(true, Tui::fg(track.color.lightest.rgb, format!("▎{}", &name[0..max_w])));
|
||||
|
||||
// name of active MIDI input
|
||||
let input = format!(">{}", track.player.midi_ins().get(0)
|
||||
.map(|port|port.short_name())
|
||||
.transpose()?
|
||||
.unwrap_or("(none)".into()));
|
||||
|
||||
// beats elapsed
|
||||
let elapsed = if let Some((_, Some(phrase))) = track.player.play_phrase().as_ref() {
|
||||
let length = phrase.read().unwrap().length;
|
||||
|
|
@ -174,40 +182,37 @@ render!(<Tui>|self: ArrangerVHeader<'a>|row!(
|
|||
let elapsed = self.timebase.format_beats_1_short(
|
||||
(elapsed as usize % length) as f64
|
||||
);
|
||||
format!("▎+{elapsed:>}")
|
||||
format!("+{elapsed:>}")
|
||||
} else {
|
||||
String::from("▎")
|
||||
String::new()
|
||||
};
|
||||
|
||||
// beats until switchover
|
||||
let until_next = track.player.next_phrase().as_ref().map(|(t, _)|{
|
||||
let target = t.pulse.get();
|
||||
let current = self.current.pulse.get();
|
||||
if target > current {
|
||||
let remaining = target - current;
|
||||
format!("▎-{:>}", self.timebase.format_beats_0_short(remaining))
|
||||
format!("-{:>}", self.timebase.format_beats_0_short(remaining))
|
||||
} else {
|
||||
String::new()
|
||||
}
|
||||
}).unwrap_or(String::from("▎"));
|
||||
let timer = col!([until_next, elapsed]);
|
||||
// name of active MIDI input
|
||||
let _input = format!("▎>{}", track.player.midi_ins().get(0)
|
||||
.map(|port|port.short_name())
|
||||
.transpose()?
|
||||
.unwrap_or("(none)".into()));
|
||||
});
|
||||
|
||||
// name of active MIDI output
|
||||
let _output = format!("▎<{}", track.player.midi_outs().get(0)
|
||||
let output = format!("<{}", track.player.midi_outs().get(0)
|
||||
.map(|port|port.short_name())
|
||||
.transpose()?
|
||||
.unwrap_or("(none)".into()));
|
||||
Tui::push_x(self.scenes_w,
|
||||
Tui::bg(track.color().base.rgb,
|
||||
Tui::min_xy(w as u16, self.header_h,
|
||||
col!([name, timer]))))
|
||||
Tui::min_xy(w as u16, self.header_h, row!([
|
||||
col!(!["▎", "▎", "▎", "▎", "▎", "▎",]),
|
||||
col!(![name, input, output, elapsed, until_next, output])]))))
|
||||
}
|
||||
));
|
||||
|
||||
pub struct ArrangerVContent<'a> {
|
||||
pub struct ArrangerVBody<'a> {
|
||||
size: &'a Measure<Tui>,
|
||||
scenes: &'a Vec<ArrangerScene>,
|
||||
tracks: &'a Vec<ArrangerTrack>,
|
||||
|
|
@ -216,7 +221,7 @@ pub struct ArrangerVContent<'a> {
|
|||
header_h: u16,
|
||||
}
|
||||
|
||||
impl<'a> From<(&'a ArrangerTui, usize)> for ArrangerVContent<'a> {
|
||||
impl<'a> From<(&'a ArrangerTui, usize)> for ArrangerVBody<'a> {
|
||||
fn from ((state, factor): (&'a ArrangerTui, usize)) -> Self {
|
||||
Self {
|
||||
size: &state.size,
|
||||
|
|
@ -229,7 +234,7 @@ impl<'a> From<(&'a ArrangerTui, usize)> for ArrangerVContent<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
render!(<Tui>|self: ArrangerVContent<'a>|Fixed::h(
|
||||
render!(<Tui>|self: ArrangerVBody<'a>|Fixed::h(
|
||||
(self.size.h() as u16).saturating_sub(self.header_h),
|
||||
col!((scene, pulses) in self.scenes.iter().zip(self.rows.iter().map(|row|row.0)) => {
|
||||
let height = 1.max((pulses / PPQ) as u16);
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ pub trait ArrangerTrackApi: HasPlayer + Send + Sync + Sized {
|
|||
tracks.iter().map(|s|s.name().read().unwrap().len()).fold(0, usize::max)
|
||||
}
|
||||
|
||||
const MIN_WIDTH: usize = 3;
|
||||
const MIN_WIDTH: usize = 6;
|
||||
|
||||
fn width_inc (&mut self) {
|
||||
*self.width_mut() += 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue