mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
add titles to phrase list and editor
This commit is contained in:
parent
bfe51cecdf
commit
944cf984ef
1 changed files with 21 additions and 13 deletions
|
|
@ -44,9 +44,7 @@ impl Handle<Tui> for Sequencer<Tui> {
|
||||||
impl Content for PhrasePool<Tui> {
|
impl Content for PhrasePool<Tui> {
|
||||||
type Engine = Tui;
|
type Engine = Tui;
|
||||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||||
col!(
|
let content = col!((i, _) in self.phrases.iter().enumerate() =>
|
||||||
"Phrases:".fill_x().fixed_y(2),
|
|
||||||
col!((i, phrase) in self.phrases.iter().enumerate() =>
|
|
||||||
Layers::new(|add|{
|
Layers::new(|add|{
|
||||||
add(&format!(" {i}").fixed_y(2).bg(if i == self.phrase {
|
add(&format!(" {i}").fixed_y(2).bg(if i == self.phrase {
|
||||||
Color::Rgb(40, 50, 30)
|
Color::Rgb(40, 50, 30)
|
||||||
|
|
@ -56,7 +54,6 @@ impl Content for PhrasePool<Tui> {
|
||||||
if self.focused && i == self.phrase { add(&CORNERS)?; }
|
if self.focused && i == self.phrase { add(&CORNERS)?; }
|
||||||
Ok(())
|
Ok(())
|
||||||
}))
|
}))
|
||||||
)
|
|
||||||
.fill_xy()
|
.fill_xy()
|
||||||
.bg(Color::Rgb(28, 35, 25))
|
.bg(Color::Rgb(28, 35, 25))
|
||||||
.border(Lozenge(Style::default()
|
.border(Lozenge(Style::default()
|
||||||
|
|
@ -65,7 +62,12 @@ impl Content for PhrasePool<Tui> {
|
||||||
Color::Rgb(100, 110, 40)
|
Color::Rgb(100, 110, 40)
|
||||||
} else {
|
} else {
|
||||||
Color::Rgb(70, 80, 50)
|
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> {
|
impl Handle<Tui> for PhrasePool<Tui> {
|
||||||
|
|
@ -114,9 +116,9 @@ impl Content for PhraseEditor<Tui> {
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}).min_x(10);
|
}).min_x(10);
|
||||||
let content = lay!(
|
let piano_roll = lay!(
|
||||||
// keys
|
// 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(()) }
|
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).shrink_y(2), &|cell, x, y|{
|
||||||
let y = y + self.note_axis.start as u16;
|
let y = y + self.note_axis.start as u16;
|
||||||
|
|
@ -126,7 +128,7 @@ impl Content for PhraseEditor<Tui> {
|
||||||
}))
|
}))
|
||||||
}).fill_y(),
|
}).fill_y(),
|
||||||
// playhead
|
// 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 {
|
if let Some(phrase) = &self.phrase {
|
||||||
let time_0 = self.time_axis.start;
|
let time_0 = self.time_axis.start;
|
||||||
let time_z = self.time_axis.scale;
|
let time_z = self.time_axis.scale;
|
||||||
|
|
@ -145,7 +147,7 @@ impl Content for PhraseEditor<Tui> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}).fill_x(),
|
}).fill_x(),
|
||||||
// notes
|
// 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;
|
let offset = Self::H_KEYS_OFFSET as u16;
|
||||||
if to.area().h() < 2 || to.area().w() < offset { return Ok(()) }
|
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).shrink_y(2);
|
||||||
|
|
@ -160,7 +162,7 @@ impl Content for PhraseEditor<Tui> {
|
||||||
}))
|
}))
|
||||||
}).fill_x(),
|
}).fill_x(),
|
||||||
// note cursor
|
// note cursor
|
||||||
CustomWidget::new(|_|Ok(Some([1,1])), |to: &mut TuiOutput|{
|
CustomWidget::new(|_|Ok(Some([1u16,1u16])), |to: &mut TuiOutput|{
|
||||||
let area = to.area();
|
let area = to.area();
|
||||||
if let (Some(time), Some(note)) = (self.time_axis.point, self.note_axis.point) {
|
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;
|
let x = area.x() + Self::H_KEYS_OFFSET as u16 + time as u16;
|
||||||
|
|
@ -171,7 +173,7 @@ impl Content for PhraseEditor<Tui> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
// zoom
|
// 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 [x, y, w, h] = to.area.xywh();
|
||||||
let quant = ppq_to_name(self.time_axis.scale);
|
let quant = ppq_to_name(self.time_axis.scale);
|
||||||
Ok(to.blit(
|
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))
|
.bg(Color::Rgb(40, 50, 30))
|
||||||
.border(Lozenge(Style::default()
|
.border(Lozenge(Style::default()
|
||||||
.bg(Color::Rgb(40, 50, 30))
|
.bg(Color::Rgb(40, 50, 30))
|
||||||
|
|
@ -190,7 +193,12 @@ impl Content for PhraseEditor<Tui> {
|
||||||
Color::Rgb(100, 110, 40)
|
Color::Rgb(100, 110, 40)
|
||||||
} else {
|
} else {
|
||||||
Color::Rgb(70, 80, 50)
|
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> {
|
impl Handle<Tui> for PhraseEditor<Tui> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue