mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 13:16:44 +01:00
fix track title and corners overlap
This commit is contained in:
parent
db5a96a7e4
commit
0f6c09cf2b
4 changed files with 80 additions and 68 deletions
|
|
@ -1,5 +1,5 @@
|
|||
use crate::*;
|
||||
/// The standalone arranger consists of transport, clip grid, and sequencer.
|
||||
/// Layout for standalone arranger app.
|
||||
impl Content for Arranger<Tui> {
|
||||
type Engine = Tui;
|
||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||
|
|
@ -19,7 +19,7 @@ impl Content for Arranger<Tui> {
|
|||
)
|
||||
)
|
||||
)
|
||||
).fill_xy()
|
||||
)
|
||||
}
|
||||
}
|
||||
impl Content for ArrangerStatusBar {
|
||||
|
|
@ -38,8 +38,8 @@ impl Content for ArrangerStatusBar {
|
|||
.fg(Color::Rgb(0, 0, 0))
|
||||
.bold(true);
|
||||
row!(label, " ", match self {
|
||||
Self::ArrangementMix =>
|
||||
"[G]et [S]et [A]dd [I]nsert [D]uplicate [E]dit [C]olor",
|
||||
Self::ArrangementClip =>
|
||||
"[G]et [S]et [A]dd [I]nsert [D]uplicate [E]dit [C]olor [,.]Choose",
|
||||
Self::PhrasePool =>
|
||||
"[A]ppend [I]nsert [D]uplicate [C]olor re[N]ame leng[T]h [,.]Move [<>]Resize",
|
||||
_ => ""
|
||||
|
|
@ -120,6 +120,55 @@ impl<'a> Content for VerticalArranger<'a, Tui> {
|
|||
Ok(())
|
||||
}))?;
|
||||
|
||||
// track titles
|
||||
let track_titles = row!((track, w) in tracks.iter().zip(cols.iter().map(|col|col.0))=>{
|
||||
let name = track.name.read().unwrap();
|
||||
let max_w = w.saturating_sub(1).min(name.len());
|
||||
(&format!("▎{}", &name[0..max_w]).as_str())
|
||||
.min_xy(w as u16, 2)
|
||||
.bg(track.color)
|
||||
.push_x(offset - 1)
|
||||
});
|
||||
|
||||
// scene titles
|
||||
let scene_name = |scene, playing: bool, height|row!(
|
||||
if playing { "▶ " } else { " " },
|
||||
(scene as &Scene).name.read().unwrap().as_str(),
|
||||
).fixed_xy(offset.saturating_sub(1), height);
|
||||
|
||||
// scene clips
|
||||
let scene_clip = |scene, track: usize, w: u16, h: u16|Layers::new(move |add|{
|
||||
let mut color = clip_bg;
|
||||
match (tracks.get(track), (scene as &Scene).clips.get(track)) {
|
||||
(Some(_), Some(Some(phrase))) => {
|
||||
let name = &(phrase as &Arc<RwLock<Phrase>>).read().unwrap().name;
|
||||
let name = format!("{}", name);
|
||||
let max_w = name.len().min((w as usize).saturating_sub(2));
|
||||
add(&name.as_str()[0..max_w].push_x(1).fixed_x(w))?;
|
||||
color = (phrase as &Arc<RwLock<Phrase>>).read().unwrap().color;
|
||||
},
|
||||
_ => {}
|
||||
};
|
||||
add(&Background(color))
|
||||
}).fixed_xy(w, h);
|
||||
|
||||
add(&col!(track_titles, col!(
|
||||
// scenes:
|
||||
(scene, pulses) in scenes.iter().zip(rows.iter().map(|row|row.0)) => {
|
||||
let height = 1.max((pulses / PPQ) as u16);
|
||||
let playing = scene.is_playing(tracks);
|
||||
Stack::right(move |add| {
|
||||
// scene title:
|
||||
add(&scene_name(scene, playing, height).bg(scene.color))?;
|
||||
// clip per track:
|
||||
for (track, w) in cols.iter().map(|col|col.0).enumerate() {
|
||||
add(&scene_clip(scene, track, w as u16, height))?;
|
||||
}
|
||||
Ok(())
|
||||
}).fixed_y(height)
|
||||
}
|
||||
)))?;
|
||||
|
||||
// cursor
|
||||
add(&CustomWidget::new(|_|Ok(Some([0,0])), move|to: &mut TuiOutput|{
|
||||
let area = to.area();
|
||||
|
|
@ -165,63 +214,19 @@ impl<'a> Content for VerticalArranger<'a, Tui> {
|
|||
if focused {
|
||||
if let Some(clip_area) = clip_area {
|
||||
to.render_in(clip_area, &CORNERS)?;
|
||||
to.fill_bg(clip_area, Color::Rgb(40, 50, 30));
|
||||
//to.fill_bg(clip_area, Color::Rgb(40, 50, 30));
|
||||
} else if let Some(track_area) = track_area {
|
||||
to.render_in(track_area.clip_h(2), &CORNERS)?;
|
||||
to.fill_bg(track_area, Color::Rgb(40, 50, 30));
|
||||
//to.fill_bg(track_area, Color::Rgb(40, 50, 30));
|
||||
} else if let Some(scene_area) = scene_area {
|
||||
to.render_in(scene_area.clip_w(offset-1), &CORNERS)?;
|
||||
to.fill_bg(scene_area, Color::Rgb(40, 50, 30));
|
||||
//to.fill_bg(scene_area, Color::Rgb(40, 50, 30));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}))?;
|
||||
|
||||
let track_titles = row!((track, w) in tracks.iter().zip(cols.iter().map(|col|col.0))=>{
|
||||
let name = track.name.read().unwrap();
|
||||
let max_w = w.min(name.len());
|
||||
(&format!("▎{}", &name[0..max_w]).as_str())
|
||||
.min_xy(w as u16, 2)
|
||||
.bg(track.color)
|
||||
.push_x(offset - 1)
|
||||
});
|
||||
|
||||
let scene_name = |scene, playing: bool, height|row!(
|
||||
if playing { "▶ " } else { " " },
|
||||
(scene as &Scene).name.read().unwrap().as_str(),
|
||||
).fixed_xy(offset.saturating_sub(1), height);
|
||||
|
||||
let scene_clip = |scene, track: usize, w: u16, h: u16|Layers::new(move |add|{
|
||||
let mut color = clip_bg;
|
||||
match (tracks.get(track), (scene as &Scene).clips.get(track)) {
|
||||
(Some(_), Some(Some(phrase))) => {
|
||||
let name = &(phrase as &Arc<RwLock<Phrase>>).read().unwrap().name;
|
||||
let name = format!("{}", name);
|
||||
let max_w = name.len().min((w as usize).saturating_sub(2));
|
||||
add(&name.as_str()[0..max_w].push_x(1).fixed_x(w))?;
|
||||
color = (phrase as &Arc<RwLock<Phrase>>).read().unwrap().color;
|
||||
},
|
||||
_ => {}
|
||||
};
|
||||
add(&Background(color))
|
||||
}).fixed_xy(w, h);
|
||||
|
||||
add(&col!(track_titles, col!(
|
||||
// scenes:
|
||||
(scene, pulses) in scenes.iter().zip(rows.iter().map(|row|row.0)) => {
|
||||
let height = 1.max((pulses / PPQ) as u16);
|
||||
let playing = scene.is_playing(tracks);
|
||||
Stack::right(move |add| {
|
||||
// scene title:
|
||||
add(&scene_name(scene, playing, height).bg(scene.color))?;
|
||||
// clip per track:
|
||||
for (track, w) in cols.iter().map(|col|col.0).enumerate() {
|
||||
add(&scene_clip(scene, track, w as u16, height))?;
|
||||
}
|
||||
Ok(())
|
||||
}).fixed_y(height)
|
||||
}
|
||||
)))
|
||||
Ok(())
|
||||
}).bg(bg).border(border)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue