mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +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|{
|
render!(<Tui>|self: ArrangerTui|{
|
||||||
let arranger = ||lay!(|add|{
|
let arranger = ||lay!(|add|{
|
||||||
let color = self.color;
|
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))))?;
|
add(&Fill::wh(Lozenge(Style::default().fg(color.light.rgb).bg(color.darker.rgb))))?;
|
||||||
match self.mode {
|
match self.mode {
|
||||||
ArrangerMode::H => todo!("horizontal arranger"),
|
ArrangerMode::H => todo!("horizontal arranger"),
|
||||||
ArrangerMode::V(factor) => add(&lay!(![
|
ArrangerMode::V(factor) => add(&lay!(![
|
||||||
ArrangerVColumnSeparator::from(self),
|
ArrangerVColSep::from(self),
|
||||||
ArrangerVRowSeparator::from((self, factor)),
|
ArrangerVRowSep::from((self, factor)),
|
||||||
col!(![
|
col!(![
|
||||||
ArrangerVHeader::from(self),
|
ArrangerVHead::from(self),
|
||||||
ArrangerVContent::from((self, factor)),
|
ArrangerVBody::from((self, factor)),
|
||||||
]),
|
]),
|
||||||
ArrangerVCursor::from((self, factor)),
|
ArrangerVCursor::from((self, factor)),
|
||||||
])),
|
])),
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
pub struct ArrangerVColumnSeparator {
|
pub struct ArrangerVColSep {
|
||||||
cols: Vec<(usize, usize)>,
|
cols: Vec<(usize, usize)>,
|
||||||
scenes_w: u16,
|
scenes_w: u16,
|
||||||
sep_fg: Color,
|
sep_fg: Color,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&ArrangerTui> for ArrangerVColumnSeparator {
|
impl From<&ArrangerTui> for ArrangerVColSep {
|
||||||
fn from (state: &ArrangerTui) -> Self {
|
fn from (state: &ArrangerTui) -> Self {
|
||||||
Self {
|
Self {
|
||||||
cols: track_widths(state.tracks()),
|
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));
|
let style = Some(Style::default().fg(self.sep_fg));
|
||||||
Ok(for x in self.cols.iter().map(|col|col.1) {
|
Ok(for x in self.cols.iter().map(|col|col.1) {
|
||||||
let x = self.scenes_w + to.area().x() + x as u16;
|
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)>,
|
rows: Vec<(usize, usize)>,
|
||||||
sep_fg: Color,
|
sep_fg: Color,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<(&ArrangerTui, usize)> for ArrangerVRowSeparator {
|
impl From<(&ArrangerTui, usize)> for ArrangerVRowSep {
|
||||||
fn from ((state, factor): (&ArrangerTui, usize)) -> Self {
|
fn from ((state, factor): (&ArrangerTui, usize)) -> Self {
|
||||||
Self {
|
Self {
|
||||||
rows: ArrangerScene::ppqs(state.scenes(), factor),
|
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) {
|
Ok(for y in self.rows.iter().map(|row|row.1) {
|
||||||
let y = to.area().y() + (y / PPQ) as u16 + 1;
|
let y = to.area().y() + (y / PPQ) as u16 + 1;
|
||||||
if y >= to.buffer.area.height { break }
|
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>,
|
tracks: &'a Vec<ArrangerTrack>,
|
||||||
cols: Vec<(usize, usize)>,
|
cols: Vec<(usize, usize)>,
|
||||||
focused: bool,
|
focused: bool,
|
||||||
|
|
@ -146,7 +146,7 @@ pub struct ArrangerVHeader<'a> {
|
||||||
current: &'a Arc<Moment>,
|
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 {
|
fn from (state: &'a ArrangerTui) -> Self {
|
||||||
Self {
|
Self {
|
||||||
tracks: &state.tracks,
|
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)) => {
|
(track, w) in self.tracks.iter().zip(self.cols.iter().map(|col|col.0)) => {
|
||||||
|
|
||||||
// name and width of track
|
// name and width of track
|
||||||
let name = track.name().read().unwrap();
|
let name = track.name().read().unwrap();
|
||||||
let max_w = w.saturating_sub(1).min(name.len()).max(2);
|
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 = 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
|
// beats elapsed
|
||||||
let elapsed = if let Some((_, Some(phrase))) = track.player.play_phrase().as_ref() {
|
let elapsed = if let Some((_, Some(phrase))) = track.player.play_phrase().as_ref() {
|
||||||
let length = phrase.read().unwrap().length;
|
let length = phrase.read().unwrap().length;
|
||||||
|
|
@ -174,40 +182,37 @@ render!(<Tui>|self: ArrangerVHeader<'a>|row!(
|
||||||
let elapsed = self.timebase.format_beats_1_short(
|
let elapsed = self.timebase.format_beats_1_short(
|
||||||
(elapsed as usize % length) as f64
|
(elapsed as usize % length) as f64
|
||||||
);
|
);
|
||||||
format!("▎+{elapsed:>}")
|
format!("+{elapsed:>}")
|
||||||
} else {
|
} else {
|
||||||
String::from("▎")
|
String::new()
|
||||||
};
|
};
|
||||||
|
|
||||||
// beats until switchover
|
// beats until switchover
|
||||||
let until_next = track.player.next_phrase().as_ref().map(|(t, _)|{
|
let until_next = track.player.next_phrase().as_ref().map(|(t, _)|{
|
||||||
let target = t.pulse.get();
|
let target = t.pulse.get();
|
||||||
let current = self.current.pulse.get();
|
let current = self.current.pulse.get();
|
||||||
if target > current {
|
if target > current {
|
||||||
let remaining = target - current;
|
let remaining = target - current;
|
||||||
format!("▎-{:>}", self.timebase.format_beats_0_short(remaining))
|
format!("-{:>}", self.timebase.format_beats_0_short(remaining))
|
||||||
} else {
|
} else {
|
||||||
String::new()
|
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
|
// 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())
|
.map(|port|port.short_name())
|
||||||
.transpose()?
|
.transpose()?
|
||||||
.unwrap_or("(none)".into()));
|
.unwrap_or("(none)".into()));
|
||||||
Tui::push_x(self.scenes_w,
|
Tui::push_x(self.scenes_w,
|
||||||
Tui::bg(track.color().base.rgb,
|
Tui::bg(track.color().base.rgb,
|
||||||
Tui::min_xy(w as u16, self.header_h,
|
Tui::min_xy(w as u16, self.header_h, row!([
|
||||||
col!([name, timer]))))
|
col!(!["▎", "▎", "▎", "▎", "▎", "▎",]),
|
||||||
|
col!(![name, input, output, elapsed, until_next, output])]))))
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
pub struct ArrangerVContent<'a> {
|
pub struct ArrangerVBody<'a> {
|
||||||
size: &'a Measure<Tui>,
|
size: &'a Measure<Tui>,
|
||||||
scenes: &'a Vec<ArrangerScene>,
|
scenes: &'a Vec<ArrangerScene>,
|
||||||
tracks: &'a Vec<ArrangerTrack>,
|
tracks: &'a Vec<ArrangerTrack>,
|
||||||
|
|
@ -216,7 +221,7 @@ pub struct ArrangerVContent<'a> {
|
||||||
header_h: u16,
|
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 {
|
fn from ((state, factor): (&'a ArrangerTui, usize)) -> Self {
|
||||||
Self {
|
Self {
|
||||||
size: &state.size,
|
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),
|
(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)) => {
|
col!((scene, pulses) in self.scenes.iter().zip(self.rows.iter().map(|row|row.0)) => {
|
||||||
let height = 1.max((pulses / PPQ) as u16);
|
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)
|
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) {
|
fn width_inc (&mut self) {
|
||||||
*self.width_mut() += 1;
|
*self.width_mut() += 1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue