reenable inc/dec phrase

This commit is contained in:
🪞👃🪞 2024-07-11 21:32:12 +03:00
parent c3040cef1c
commit 2c8f4857dd
11 changed files with 217 additions and 585 deletions

View file

@ -3,12 +3,12 @@ use crate::model::*;
use crate::view::*;
pub struct ArrangerView<'a> {
pub scenes: &'a[Scene],
pub tracks: &'a[Track],
pub cursor: (usize, usize),
pub focused: bool,
pub entered: bool,
pub vertical: bool,
scenes: &'a[Scene],
tracks: &'a[Track],
cursor: (usize, usize),
focused: bool,
entered: bool,
vertical: bool,
}
impl<'a> ArrangerView<'a> {
@ -101,9 +101,9 @@ impl<'a> ArrangerView<'a> {
bg_color
);
if i == 0 {
self.vertical_scenes(buf, x2+1, y2+2, area.height);
self.vertical_scenes(buf, x2+1, y2+2, area.height)?;
} else if i < columns.len() {
self.vertical_clips(buf, x2+1, y2+2, area.height, i - 1);
self.vertical_clips(buf, x2+1, y2+2, area.height, i - 1)?;
};
let style = Some(highlight(self.focused, focus_column).bold());
if i > 0 {
@ -113,9 +113,9 @@ impl<'a> ArrangerView<'a> {
Style::default().green()
} else {
Style::default().black()
}));
}))?;
}
title.blit(buf, x2+2, y2, style);
title.blit(buf, x2+2, y2, style)?;
x2 = x2 + w + 3;
}
fill_bg(
@ -128,12 +128,12 @@ impl<'a> ArrangerView<'a> {
bg_color
);
if self.focused {
HELP.blit(buf, x + 2, y + height - 1, Some(Style::default().dim()));
HELP.blit(buf, x + 2, y + height - 1, Some(Style::default().dim()))?;
}
Ok(area)
}
fn vertical_scenes (&self, buf: &mut Buffer, x: u16, y: u16, height: u16) -> u16 {
fn vertical_scenes (&self, buf: &mut Buffer, x: u16, y: u16, height: u16) -> Usually<u16> {
let mut index = 0usize;
loop {
if index >= self.scenes.len() {
@ -142,24 +142,25 @@ impl<'a> ArrangerView<'a> {
if y + index as u16 >= height {
break
}
self.vertical_scene(buf, x, y + index as u16, index);
self.vertical_scene(buf, x, y + index as u16, index)?;
index = index + 1;
}
longest_scene_name(&self.scenes)
Ok(longest_scene_name(&self.scenes))
}
fn vertical_scene (&self, buf: &mut Buffer, x: u16, y: u16, index: usize) {
fn vertical_scene (&self, buf: &mut Buffer, x: u16, y: u16, index: usize) -> Usually<()> {
if let Some(scene) = self.scenes.get(index) {
let style = Some(highlight(
self.focused,
(0 == self.cursor.0) && (index + 1 == self.cursor.1)
).bold());
"".blit(buf, x, y, style);
scene.name.blit(buf, x + 2, y, style);
"".blit(buf, x, y, style)?;
scene.name.blit(buf, x + 2, y, style)?;
}
Ok(())
}
fn vertical_clips (&self, buf: &mut Buffer, x: u16, y: u16, height: u16, track: usize) -> u16 {
fn vertical_clips (&self, buf: &mut Buffer, x: u16, y: u16, height: u16, track: usize) -> Usually<u16> {
let mut index = 0;
let mut width = 10;
loop {
@ -169,14 +170,14 @@ impl<'a> ArrangerView<'a> {
if y + index as u16 >= height {
break
}
width = 10.max(self.vertical_clip(buf, x, y, track, index));
width = 10.max(self.vertical_clip(buf, x, y, track, index)?);
index = index + 1;
}
width
Ok(width)
}
fn vertical_clip (&self, buf: &mut Buffer, x: u16, y: u16, track: usize, index: usize) -> u16 {
if let Some(scene) = self.scenes.get(index) {
fn vertical_clip (&self, buf: &mut Buffer, x: u16, y: u16, track: usize, index: usize) -> Usually<u16> {
Ok(if let Some(scene) = self.scenes.get(index) {
let hi = (track + 1 == self.cursor.0) &&
(index + 1 == self.cursor.1);
let style = Some(highlight(self.focused, hi));
@ -195,11 +196,11 @@ impl<'a> ArrangerView<'a> {
} else {
format!(" ·········")
};
label.blit(buf, x, y + index, style);
label.blit(buf, x, y + index, style)?;
label.len() as u16
} else {
0u16
}
})
}
}
@ -217,16 +218,16 @@ impl<'a> ArrangerView<'a> {
});
if self.focused && self.entered {
//RailV::draw(buf, Rect { x, y, width, height });
QuarterV(Style::default().green().dim()).draw(buf, Rect { x, y, width, height });
QuarterV(Style::default().green().dim()).draw(buf, Rect { x, y, width, height })?;
//lozenge_left(buf, x, y, height, style);
//lozenge_right(buf, x + width - 1, y, height, style);
}
let mut x2 = 0;
self.horizontal_tracks(buf, area, &mut x2);
self.horizontal_tracks(buf, area, &mut x2)?;
x2 = x2 + 1;
self.horizontal_scenes(buf, area, &mut x2);
self.horizontal_scenes(buf, area, &mut x2)?;
if self.focused {
HELP.blit(buf, x + 2, y + height - 1, Some(Style::default().dim()));
HELP.blit(buf, x + 2, y + height - 1, Some(Style::default().dim()))?;
}
Ok(area)
}
@ -235,51 +236,58 @@ impl<'a> ArrangerView<'a> {
let h = (2 + self.tracks.len()) as u16;
(w, h)
}
fn horizontal_tracks (&self, buf: &mut Buffer, area: Rect, x2: &mut u16) {
fn horizontal_tracks (&self, buf: &mut Buffer, area: Rect, x2: &mut u16) -> Usually<()> {
let style = Some(Style::default().bold().not_dim().white());
let Rect { x, y, height, .. } = area;
"Mix".blit(buf, x + 1, y, style);
"Mix".blit(buf, x + 1, y, style)?;
let style = Some(Style::default().bold());
for (i, track) in self.tracks.iter().enumerate() {
let y2 = y + 1 + i as u16 * 2;
if self.cursor.0 > 0 {
if i == self.cursor.0 - 1 {
">".blit(buf, x, y2, style)?;
}
}
let label = format!(" {:8}", &track.name);
label.blit(buf, x + 1, y2, style);
"RDM".blit(buf, x + 10, y2, Some(Style::default().dim()));
" 0.0dB".blit(buf, x + 15, y2, Some(Style::default().dim()));
label.blit(buf, x + 1, y2, style)?;
"RDM".blit(buf, x + 10, y2, Some(Style::default().dim()))?;
" 0.0dB".blit(buf, x + 15, y2, Some(Style::default().dim()))?;
*x2 = (*x2).max(label.len() as u16 + 13);
}
"".blit(buf, x + *x2, y, style);
"".blit(buf, x + *x2, y, style)?;
for y in y+1..y+height-1 {
"".blit(buf, x + *x2, y, style);
"".blit(buf, x + *x2, y, style)?;
}
//"╵".blit(buf, x + x2, y+height-1, style);
Ok(())
}
fn horizontal_scenes (&self, buf: &mut Buffer, area: Rect, x2: &mut u16) {
fn horizontal_scenes (&self, buf: &mut Buffer, area: Rect, x2: &mut u16) -> Usually<()> {
let Rect { x, y, height, .. } = area;
let bold = Some(Style::default().bold());
let sep = Some(Style::default().dim());
for scene in self.scenes.iter() {
let mut x3 = scene.name.len() as u16;
scene.name.blit(buf, x + *x2, y, bold);
scene.name.blit(buf, x + *x2, y, bold)?;
for (i, clip) in scene.clips.iter().enumerate() {
if let Some(clip) = clip {
if let Some(phrase) = self.tracks[i].phrases.get(*clip) {
let y2 = y + 1 + i as u16 * 2;
let label = format!("{}", &phrase.name);
label.blit(buf, x + *x2, y2, None);
label.blit(buf, x + *x2, y2, None)?;
x3 = x3.max(label.len() as u16)
}
}
}
*x2 = *x2 + x3;
"".blit(buf, x + *x2, y, sep);
"".blit(buf, x + *x2, y, sep)?;
for y in y+1..y+height-1 {
"".blit(buf, x + *x2, y, sep);
"".blit(buf, x + *x2, y, sep)?;
}
"".blit(buf, x + *x2, y+height-1, sep);
"".blit(buf, x + *x2, y+height-1, sep)?;
*x2 = *x2 + 1;
}
Ok(())
}
}