mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
store updated phrase length; enter/exit phrase editor
This commit is contained in:
parent
ff342963a1
commit
d29dd56198
3 changed files with 42 additions and 34 deletions
|
|
@ -20,9 +20,9 @@ impl Content for PhrasePool<Tui> {
|
|||
let Phrase { ref name, color, length, .. } = *phrase.read().unwrap();
|
||||
|
||||
let row1 = lay!(format!(" {i}").align_w().fill_x(),
|
||||
if let Some(PhrasePoolMode::Length(phrase, length, focus)) = self.mode {
|
||||
if let Some(PhrasePoolMode::Length(phrase, new_length, focus)) = self.mode {
|
||||
if self.focused && i == phrase {
|
||||
PhraseLength::new(length, Some(focus))
|
||||
PhraseLength::new(new_length, Some(focus))
|
||||
} else {
|
||||
PhraseLength::new(length, None)
|
||||
}
|
||||
|
|
@ -71,25 +71,25 @@ impl Content for PhrasePool<Tui> {
|
|||
impl Content for PhraseEditor<Tui> {
|
||||
type Engine = Tui;
|
||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||
let field_bg = Color::Rgb(28, 35, 25);
|
||||
let toolbar = Stack::down(move|add|{
|
||||
//let name = format!("{:>9}", self.name.read().unwrap().as_str());
|
||||
//add(&col!("Track:", TuiStyle::bg(name.as_str(), field_bg)))?;
|
||||
if let Some(phrase) = &self.phrase {
|
||||
let phrase = phrase.read().unwrap();
|
||||
let length = format!("{}q{}p", phrase.length / PPQ, phrase.length % PPQ);
|
||||
let length = format!("{:>9}", &length);
|
||||
let loop_on = format!("{:>9}", if phrase.loop_on { "on" } else { "off" });
|
||||
let loop_start = format!("{:>9}", phrase.loop_start);
|
||||
let loop_end = format!("{:>9}", phrase.loop_length);
|
||||
add(&"")?;
|
||||
add(&col!("Length:", TuiStyle::bg(length.as_str(), field_bg)))?;
|
||||
add(&col!("Loop:", TuiStyle::bg(loop_on.as_str(), field_bg)))?;
|
||||
add(&col!("L. start:", TuiStyle::bg(loop_start.as_str(), field_bg)))?;
|
||||
add(&col!("L. length:", TuiStyle::bg(loop_end.as_str(), field_bg)))?;
|
||||
}
|
||||
Ok(())
|
||||
}).min_x(10);
|
||||
//let field_bg = Color::Rgb(28, 35, 25);
|
||||
//let toolbar = Stack::down(move|add|{
|
||||
////let name = format!("{:>9}", self.name.read().unwrap().as_str());
|
||||
////add(&col!("Track:", TuiStyle::bg(name.as_str(), field_bg)))?;
|
||||
//if let Some(phrase) = &self.phrase {
|
||||
//let phrase = phrase.read().unwrap();
|
||||
//let length = format!("{}q{}p", phrase.length / PPQ, phrase.length % PPQ);
|
||||
//let length = format!("{:>9}", &length);
|
||||
//let loop_on = format!("{:>9}", if phrase.loop_on { "on" } else { "off" });
|
||||
//let loop_start = format!("{:>9}", phrase.loop_start);
|
||||
//let loop_end = format!("{:>9}", phrase.loop_length);
|
||||
//add(&"")?;
|
||||
//add(&col!("Length:", TuiStyle::bg(length.as_str(), field_bg)))?;
|
||||
//add(&col!("Loop:", TuiStyle::bg(loop_on.as_str(), field_bg)))?;
|
||||
//add(&col!("L. start:", TuiStyle::bg(loop_start.as_str(), field_bg)))?;
|
||||
//add(&col!("L. length:", TuiStyle::bg(loop_end.as_str(), field_bg)))?;
|
||||
//}
|
||||
//Ok(())
|
||||
//}).min_x(10);
|
||||
let piano_roll = lay!(
|
||||
// keys
|
||||
CustomWidget::new(|_|Ok(Some([32u16,4u16])), |to: &mut TuiOutput|{
|
||||
|
|
@ -137,12 +137,14 @@ impl Content for PhraseEditor<Tui> {
|
|||
}).fill_x(),
|
||||
// note cursor
|
||||
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;
|
||||
let y = area.y() + 1 + note as u16 / 2;
|
||||
let c = if note % 2 == 0 { "▀" } else { "▄" };
|
||||
to.blit(&c, x, y, self.style_focus());
|
||||
if self.entered {
|
||||
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;
|
||||
let y = area.y() + 1 + note as u16 / 2;
|
||||
let c = if note % 2 == 0 { "▀" } else { "▄" };
|
||||
to.blit(&c, x, y, self.style_focus());
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}),
|
||||
|
|
@ -158,7 +160,7 @@ impl Content for PhraseEditor<Tui> {
|
|||
))
|
||||
}),
|
||||
);
|
||||
let content = row!(toolbar, piano_roll)
|
||||
let content = row!(piano_roll)
|
||||
.fill_x()
|
||||
.bg(Color::Rgb(40, 50, 30))
|
||||
.border(Lozenge(Style::default()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue