wip: sequencer edit mode

This commit is contained in:
🪞👃🪞 2024-10-17 22:20:36 +03:00
parent eac8986548
commit 0af5f97244
5 changed files with 72 additions and 147 deletions

View file

@ -94,7 +94,7 @@ impl Content for PhraseEditor<Tui> {
// keys
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|{
Ok(to.buffer_update(to.area().set_w(5), &|cell, x, y|{
let y = y + self.note_axis.start as u16;
if x < self.keys.area.width && y < self.keys.area.height {
*cell = self.keys.get(x, y).clone()
@ -124,7 +124,7 @@ impl Content for PhraseEditor<Tui> {
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);
let area = to.area().push_x(offset).shrink_x(offset);
Ok(to.buffer_update(area, &move |cell, x, y|{
cell.set_bg(Color::Rgb(20, 20, 20));
let src_x = ((x as usize + self.time_axis.start) * self.time_axis.scale) as usize;
@ -148,33 +148,27 @@ impl Content for PhraseEditor<Tui> {
}
Ok(())
}),
// zoom
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(
&quant,
x + w - 1 - quant.len() as u16,
y + h - 2,
self.style_focus()
))
}),
);
let content = row!(piano_roll)
.fill_x()
.bg(Color::Rgb(40, 50, 30))
.border(Lozenge(Style::default()
.bg(Color::Rgb(40, 50, 30))
.fg(if self.focused {
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))
let border_color =
if self.focused { Color::Rgb(100, 110, 40) } else { Color::Rgb(70, 80, 50) };
let title_color =
if self.focused { Color::Rgb(150, 160, 90) } else { Color::Rgb(120, 130, 100) };
let border =
Lozenge(Style::default().bg(Color::Rgb(40, 50, 30)).fg(border_color));
let content =
piano_roll.fill_x().bg(Color::Rgb(40, 50, 30)).border(border);
let title = TuiStyle::fg("Sequencer", title_color)
.push_x(1);
let zoom = TuiStyle::fg(format!("{}Zoom: {}",
if self.focused && !self.entered { "[,.] " } else { "" },
ppq_to_name(self.time_axis.scale),
), title_color).pull_x(1).align_se().fill_xy();
let enter = TuiStyle::fg(if self.focused {
if self.entered { "[Esc] Exit edit mode [A]ppend [I]nsert" } else {
"[Enter] Edit notes"
}
} else { "" }, title_color).push_x(1).align_sw().fill_xy();
lay!(content, title, enter, zoom)
}
}
impl PhraseEditor<Tui> {