add titles to phrase list and editor

This commit is contained in:
🪞👃🪞 2024-10-10 13:08:14 +03:00
parent bfe51cecdf
commit 944cf984ef

View file

@ -44,9 +44,7 @@ impl Handle<Tui> for Sequencer<Tui> {
impl Content for PhrasePool<Tui> {
type Engine = Tui;
fn content (&self) -> impl Widget<Engine = Tui> {
col!(
"Phrases:".fill_x().fixed_y(2),
col!((i, phrase) in self.phrases.iter().enumerate() =>
let content = col!((i, _) in self.phrases.iter().enumerate() =>
Layers::new(|add|{
add(&format!(" {i}").fixed_y(2).bg(if i == self.phrase {
Color::Rgb(40, 50, 30)
@ -56,7 +54,6 @@ impl Content for PhrasePool<Tui> {
if self.focused && i == self.phrase { add(&CORNERS)?; }
Ok(())
}))
)
.fill_xy()
.bg(Color::Rgb(28, 35, 25))
.border(Lozenge(Style::default()
@ -65,7 +62,12 @@ impl Content for PhrasePool<Tui> {
Color::Rgb(100, 110, 40)
} else {
Color::Rgb(70, 80, 50)
})))
})));
lay!(content, TuiStyle::fg("Phrases", if self.focused {
Color::Rgb(150, 160, 90)
} else {
Color::Rgb(120, 130, 100)
}).push_x(1))
}
}
impl Handle<Tui> for PhrasePool<Tui> {
@ -114,9 +116,9 @@ impl Content for PhraseEditor<Tui> {
}
Ok(())
}).min_x(10);
let content = lay!(
let piano_roll = lay!(
// keys
CustomWidget::new(|_|Ok(Some([32,4])), |to: &mut TuiOutput|{
CustomWidget::new(|_|Ok(Some([32u16,4u16])), |to: &mut TuiOutput|{
if to.area().h() < 2 { return Ok(()) }
Ok(to.buffer_update(to.area().set_w(5).shrink_y(2), &|cell, x, y|{
let y = y + self.note_axis.start as u16;
@ -126,7 +128,7 @@ impl Content for PhraseEditor<Tui> {
}))
}).fill_y(),
// playhead
CustomWidget::new(|_|Ok(Some([32,2])), |to: &mut TuiOutput|{
CustomWidget::new(|_|Ok(Some([32u16,2u16])), |to: &mut TuiOutput|{
if let Some(phrase) = &self.phrase {
let time_0 = self.time_axis.start;
let time_z = self.time_axis.scale;
@ -145,7 +147,7 @@ impl Content for PhraseEditor<Tui> {
Ok(())
}).fill_x(),
// notes
CustomWidget::new(|_|Ok(Some([32,4])), |to: &mut TuiOutput|{
CustomWidget::new(|_|Ok(Some([32u16,4u16])), |to: &mut TuiOutput|{
let offset = Self::H_KEYS_OFFSET as u16;
if to.area().h() < 2 || to.area().w() < offset { return Ok(()) }
let area = to.area().push_x(offset).shrink_x(offset).shrink_y(2);
@ -160,7 +162,7 @@ impl Content for PhraseEditor<Tui> {
}))
}).fill_x(),
// note cursor
CustomWidget::new(|_|Ok(Some([1,1])), |to: &mut TuiOutput|{
CustomWidget::new(|_|Ok(Some([1u16,1u16])), |to: &mut TuiOutput|{
let area = to.area();
if let (Some(time), Some(note)) = (self.time_axis.point, self.note_axis.point) {
let x = area.x() + Self::H_KEYS_OFFSET as u16 + time as u16;
@ -171,7 +173,7 @@ impl Content for PhraseEditor<Tui> {
Ok(())
}),
// zoom
CustomWidget::new(|_|Ok(Some([10,1])), |to: &mut TuiOutput|{
CustomWidget::new(|_|Ok(Some([10u16,1u16])), |to: &mut TuiOutput|{
let [x, y, w, h] = to.area.xywh();
let quant = ppq_to_name(self.time_axis.scale);
Ok(to.blit(
@ -182,7 +184,8 @@ impl Content for PhraseEditor<Tui> {
))
}),
);
row!(toolbar, content).fill_x()
let content = row!(toolbar, piano_roll)
.fill_x()
.bg(Color::Rgb(40, 50, 30))
.border(Lozenge(Style::default()
.bg(Color::Rgb(40, 50, 30))
@ -190,7 +193,12 @@ impl Content for PhraseEditor<Tui> {
Color::Rgb(100, 110, 40)
} else {
Color::Rgb(70, 80, 50)
})))
})));
lay!(content, TuiStyle::fg("Sequencer", if self.focused {
Color::Rgb(150, 160, 90)
} else {
Color::Rgb(120, 130, 100)
}).push_x(1))
}
}
impl Handle<Tui> for PhraseEditor<Tui> {