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(())
}
}

View file

@ -1,23 +1,23 @@
use crate::core::*;
use crate::view::*;
use crate::model::*;
use crate::view::{*, Direction};
pub struct ChainView<'a> {
pub focused: bool,
pub track: Option<&'a Track>,
pub vertical: bool,
pub track: Option<&'a Track>,
pub direction: Direction,
pub focused: bool,
}
impl<'a> ChainView<'a> {
pub fn horizontal (app: &'a App) -> Self {
Self::new(app, false)
Self::new(app, Direction::Right)
}
pub fn vertical (app: &'a App) -> Self {
Self::new(app, true)
Self::new(app, Direction::Down)
}
pub fn new (app: &'a App, vertical: bool) -> Self {
pub fn new (app: &'a App, direction: Direction) -> Self {
Self {
vertical,
direction,
focused: app.section == AppSection::Chain,
track: match app.track_cursor {
0 => None,
@ -28,220 +28,66 @@ impl<'a> ChainView<'a> {
}
impl<'a> Render for ChainView<'a> {
fn render (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
let style = Some(if self.focused {
Style::default().green().dim()
} else {
Style::default().dim()
});
let Rect { x, y, width, height } = area;
if self.track.is_none() {
let label = "No track selected";
label.blit(
buf,
x + (width - label.len() as u16) / 2,
y + height / 2,
Some(Style::default().dim().bold())
);
}
fill_bg(buf, area, if self.focused {
Color::Rgb(20, 45, 5)
} else {
Color::Reset
});
//lozenge_left(buf, x, y, height, style);
let (area, _plugins) = if self.track.is_some() {
if self.vertical {
self.draw_as_column(buf, area, style)?
} else {
self.draw_as_row(buf, area, style)?
fn render (&self, buf: &mut Buffer, mut area: Rect) -> Usually<Rect> {
if let Some(track) = self.track {
match self.direction {
Direction::Down => area.width = area.width.min(40),
Direction::Right => area.width = area.width.min(10),
}
fill_bg(buf, area, if self.focused { Color::Rgb(20, 45, 5) } else { Color::Reset });
self.direction
.split_focus(0, track.devices.as_slice(), if self.focused {
Style::default().green().dim()
} else {
Style::default().dim()
})
.render(buf, area)
} else {
(area, vec![])
};
//lozenge_right(buf, x + width - 1, y, height, style);
let Rect { x, y, width, height } = area;
let label = "No track selected";
let x = x + (width - label.len() as u16) / 2;
let y = y + height / 2;
label.blit(buf, x, y, Some(Style::default().dim().bold()))?;
Ok(area)
}
}
}
type Renderables<'a> = &'a [JackDevice];
impl<'a> Direction {
fn split_focus (&self, index: usize, items: Renderables<'a>, style: Style) -> SplitFocus<'a> {
SplitFocus(*self, index, items, style)
}
}
pub struct SplitFocus<'a>(pub Direction, pub usize, pub Renderables<'a>, pub Style);
impl<'a> Render for SplitFocus<'a> {
fn render (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
let Rect { mut x, mut y, mut width, mut height } = area;
let mut results = vec![];
for item in self.2.iter() {
if width == 0 || height == 0 {
break
}
let result = item.render(buf, Rect { x, y, width, height })?;
results.push(result);
match self.0 {
Direction::Down => {
y = y + result.height;
height = height.saturating_sub(result.height);
},
Direction::Right => {
x = x + result.width;
width = width.saturating_sub(result.width);
},
}
}
results
.get(self.1)
.map(|focused|Lozenge(self.3).draw(buf, *focused))
.transpose()?;
Ok(area)
}
}
impl<'a> ChainView<'a> {
pub fn draw_as_row (
&self, buf: &mut Buffer, area: Rect, style: Option<Style>
) -> Usually<(Rect, Vec<Rect>)> {
let Rect { mut x, y, width, height } = area;
let mut h = 3u16;
let mut frames = vec![];
let track = self.track.as_ref().unwrap();
for (i, device) in track.devices.iter().enumerate() {
let x2 = 0u16;
let _y2 = 1u16;
//for port in device.midi_ins()?.iter() {
//port.blit(buf, x, y + y2, Some(Style::default()));
//x2 = x2.max(port.len() as u16);
//y2 = y2 + 1;
//}
//for port in device.audio_ins()?.iter() {
//port.blit(buf, x, y + y2, Some(Style::default()));
//x2 = x2.max(port.len() as u16);
//y2 = y2 + 1;
//}
let width = width.saturating_sub(x).saturating_sub(x2);
let frame = device.state.read().unwrap()
.render(buf, Rect { x: x + x2, y, width, height })?;
let style = if i == track.device {
Some(if self.focused {
Style::default().green().bold().not_dim()
} else {
Style::default().green().dim()
})
} else {
style
};
LozengeV(style.unwrap_or(Style::default())).draw(buf, frame);
//let mut y2 = 1u16;
//for port in device.midi_outs()?.iter() {
//port.blit(buf, x + x2 + frame.width, y + y2, Some(Style::default()));
//x2 = x2.max(port.len() as u16);
//y2 = y2 + 1;
//}
//for port in device.audio_outs()?.iter() {
//port.blit(buf, x + x2 + frame.width, y + y2, Some(Style::default()));
//x2 = x2.max(port.len() as u16);
//y2 = y2 + 1;
//}
frames.push(frame);
h = h.max(frame.height);
x = x + frame.width;
}
let label = "[Add device…]";
label.blit(buf, x + 1, area.y + 1, Some(Style::default().dim()));
x = x + 1 + label.len() as u16 + 1;
Ok((Rect { x: area.x, y: area.y, width: x, height: h }, frames))
}
pub fn draw_as_column (
&self, buf: &mut Buffer, area: Rect, selected: Option<Style>
) -> Usually<(Rect, Vec<Rect>)> {
let Rect { x, mut y, width, height } = area;
let mut w = 0u16;
let mut frames = vec![];
let track = self.track.as_ref().unwrap();
for (_i, device) in track.devices.iter().enumerate() {
//let midi_ins = device.midi_ins()?;
//let midi_outs = device.midi_outs()?;
//let audio_ins = device.audio_ins()?;
//let audio_outs = device.audio_outs()?;
let device = device.state.read().unwrap();
//let style_midi = Style::default().black().bold().on_green();
//let style_audio = Style::default().black().bold().on_red();
//y = y + midi_ins.len() as u16;
let frame = device.render(buf, Rect {
x, y, width, height: height.saturating_sub(y)
})?;
frames.push(frame);
w = w.max(frame.width);
y = y + frame.height;
//y = y - midi_ins.len() as u16;
//for port in midi_ins.iter() {
//buf.set_string(x + frame.width - 10, y, &format!(" <i> MIDI {} ", port.name()?), style_midi);
//y = y + 1;
//}
//y = y - audio_ins.len() as u16;
//for port in audio_ins.iter() {
//buf.set_string(x + frame.width - 10, y, &format!(" <i> MIDI {} ", port.name()?), style_audio);
//y = y + 1;
//}
//y = y + frame.height - 1;
//y = y + midi_outs.len() as u16;
//for port in midi_outs.iter() {
//buf.set_string(x + 2, y, &format!(" <o> MIDI {} ", port.name()?), style_midi);
//y = y + 1;
//}
//y = y + audio_outs.len() as u16;
//for port in audio_outs.iter() {
//buf.set_string(x + 2, y, &format!(" <o> Audio {} ", port.name()?), style_audio);
//y = y + 1;
//}
}
if frames.len() > 0 {
Lozenge(selected.unwrap_or(Style::default()))
.draw(buf, frames[track.device]);
}
Ok((Rect { x, y: area.y, width: w, height: y - area.y }, frames))
//let area = Rect { x, y, width: 40, height: 30 };
//let mut y = area.y;
//buf.set_string(area.x, y, "│", Style::default().black());
//buf.set_string(area.x + area.width - 1, y, "│", Style::default().black());
//buf.set_string(area.x + 2, y, "Input...", Style::default().dim());
//let mut x = 0u16;
//for (i, device) in state.items.iter().enumerate() {
//let result = device.render(buf, Rect {
//x: area.x,
//y,
//width: area.width,
//height: 21//area.height.saturating_sub(y)
//})?;
//if i == state.focus {
//if state.focused {
//draw_box_styled(buf, result, Some(Style::default().green().not_dim()))
//} else {
//draw_box_styled_dotted(buf, result, Some(Style::default().green().dim()))
//};
//};
////let result = Rect { x: 0, y: 0, width: result.width, height: 21 };
//x = x.max(result.width);
//y = y + result.height;
////y = y + 1;
//buf.set_string(area.x, y, "│", Style::default().black());
//buf.set_string(area.x + area.width - 1, y, "│", Style::default().black());
//buf.set_string(area.x + 2, y, " Patch in ┐ │ └ Patch out", Style::default().dim());
//y = y + 1;
////buf.set_string(area.x, y, format!("{y}---BOT---"), Style::default().red());
////buf.set_string(area.x + area.width - 1, area.y + 1, "│", Style::default().black());
////buf.set_string(area.x + 2, y, "Patch...", Style::default().dim());
//}
//Ok(draw_box(buf, Rect {
//x: area.x,
//y: area.y,
//width: area.width,
//height: y - area.y,
//}))
}
}
//pub fn render (state: &Chain, buf: &mut Buffer, area: Rect)
//-> Usually<Rect>
//{
//let Rect { x, y, .. } = area;
//let selected = Some(if state.focused {
//Style::default().green().not_dim()
//} else {
//Style::default().green().dim()
//});
//let result = match state.view {
//ChainViewMode::Hidden => Rect { x, y, width: 0, height: 0 },
//ChainViewMode::Compact => {
//let area = Rect { x, y, width: (state.name.len() + 4) as u16, height: 3 };
//buf.set_string(area.x + 2, area.y + 1, &state.name, Style::default());
//draw_box_styled(buf, area, selected)
//},
//ChainViewMode::Row => {
//draw_box_styled(buf, area, selected);
//let (area, _) = Row::draw(buf, area, &state.items, 0)?;
//area
//},
//ChainViewMode::Column => {
//draw_as_column(state, buf, area, selected)?
//},
//};
//Ok(result)
//}
//pub enum ChainViewMode {
//Hidden,
//Compact,
//Row,
//Column,
//}

View file

@ -1,217 +0,0 @@
//#![feature(fn_traits)]
//#![feature(unboxed_closures)]
use crate::core::*;
pub trait Modal<T>: Device {
fn handle_with_state (&self, state: &mut T, event: &AppEvent) -> Usually<bool>;
}
pub trait MaxHeight: Device {
fn max_height (&self) -> u16 {
u16::MAX
}
}
impl<T: Device> MaxHeight for T {}
pub enum Collected<'a> {
Box(Box<dyn Render + Sync + 'a>),
Ref(&'a (dyn Render + Sync + 'a)),
None
}
impl<'a> Render for Collected<'a> {
fn render (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
match self {
Self::Box(item) => (*item).render(buf, area),
Self::Ref(item) => (*item).render(buf, area),
Self::None => Ok(area),
}
}
}
pub struct Collector<'a>(pub Vec<Collected<'a>>);
//impl<'a, R: Render + 'a> FnOnce<(R,)> for Collector<'a> {
//type Output = ();
//extern "rust-call" fn call_once (self, (device, ): (R,)) -> Self::Output {
//self.add(widget.into_collected());
//}
//}
impl<'a> Collector<'a> {
pub fn collect (collect: impl Fn(&mut Collector<'a>)) -> Self {
let mut items = Self(vec![]);
collect(&mut items);
items
}
fn add (mut self, widget: Collected<'a>) -> Self {
self.0.push(widget);
self
}
}
pub trait Collection<'a, T, U> {
fn add (self, widget: impl Render + 'a) -> Self;
}
//struct AppLayout {
//focus: usize,
//track_focus: usize,
//chain_focus: usize,
//device_focus: usize,
//enter: bool,
//track_enter: bool,
//chain_enter: bool,
//device_enter: bool,
//}
//impl AppLayout {
//fn grid (&self) -> &mut crate::model::sampler::Sampler {
//unimplemented!();
//}
//fn has_track (&self) -> bool {
//unimplemented!();
//}
//fn sequencer (&self) -> &mut crate::model::sampler::Sampler {
//unimplemented!();
//}
//fn chain (&self) -> &mut crate::model::sampler::Sampler {
//unimplemented!();
//}
//fn chains (&self) -> Vec<&mut crate::model::sampler::Sampler> {
//unimplemented!();
//}
//fn devices (&self) -> Vec<&mut crate::model::sampler::Sampler> {
//unimplemented!();
//}
//}
//handle!(AppLayout |self, event| {
//let mut grid = self.grid();
//let mut sequencer = self.sequencer();
//let mut devices = self.devices();
//let mut chains = self.chains();
//});
//struct FocusConst<'a, const N: usize>(
//usize,
//bool,
//[&'a mut dyn Handle; N]
//);
//impl<'a, const N: usize> Handle for FocusConst<'a, N> {
//fn handle (&mut self, event: &AppEvent) -> Usually<bool> {
//Ok(true)
//}
//}
//struct FocusDyn<'a, T: Handle>(
//usize,
//bool,
//&'a mut [&mut T]
//);
//impl<'a, T: Handle> Handle for FocusDyn<'a, T> {
//fn handle (&mut self, event: &AppEvent) -> Usually<bool> {
//Ok(true)
//}
//}
//render!(AppLayout |self, buf, area| {
//Flex::col(&[
//self.transport,
//Flex::col(&[
//self.grid,
//if self.track {
//Flex::col(&[
//self.sequencer,
//self.chain
//])
//} else {
//Flex::row(&self.chains)
//}
//])
//]).render(buf, area)
//})
//struct Flex<'a>(
//FlexDir,
//&'a [&'a dyn Render]
//);
//impl<'a> Flex<'a> {
//pub fn row (items: &'a [impl Render]) -> Self {
//Self(FlexDir::Row, items)
//}
//pub fn col (items: &'a [impl Render]) -> Self {
//Self(FlexDir::Col, items)
//}
//pub fn row_rev (items: &'a [impl Render]) -> Self {
//Self(FlexDir::RowRev, items)
//}
//pub fn col_rev (items: &'a [impl Render]) -> Self {
//Self(FlexDir::ColRev, items)
//}
//}
//enum FlexDir {
//Row,
//Col,
//RowRev,
//ColRev
//}
//impl<'a> Render for Flex<'a> {
//fn render (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
//let Rect { x, y, width, height } = area;
//let (mut x2, mut y2) = (0, 0);
//for item in self.1.iter() {
//let Rect { width, height, .. } = item.render(buf, Rect {
//x: x + x2, y: y + y2, width, height
//})?;
//let Rect { width, height, .. } = item.render(buf, match self.0 {
//FlexDir::Row => Rect {
//x: x + x2,
//y: y + y2,
//width: width - x2,
//height: height - y2,
//},
//FlexDir::Col => Rect {
//x: x + x2,
//y: y + y2,
//width: width - x2,
//height: height - y2,
//},
//FlexDir::RowRev => Rect {
//x: x + width - 1 - x2,
//y: y + y2,
//width: width - x2,
//height: height - y2,
//},
//FlexDir::ColRev => Rect {
//x: x + x2,
//y: y + height - 1 - y2,
//width: width - x2,
//height: height - y2,
//}
//})?;
//match self.0 {
//FlexDir::Row => {
//x2 = x2 + width;
//},
//FlexDir::Col => {
//y2 = y2 + height;
//},
//FlexDir::RowRev => {
//x2 = x2 + width
//},
//FlexDir::ColRev => {
//y2 = y2 + height;
//}
//}
//}
//Ok(area)
//}
//}

View file

@ -4,7 +4,6 @@ pub struct TransportView {
pub record: bool,
pub overdub: bool,
pub monitor: bool,
pub frame: usize,
pub quant: usize,
pub ppq: usize,
pub bpm: usize,
@ -18,7 +17,6 @@ impl TransportView {
monitor: app.track().map(|t|t.1.monitoring).unwrap_or(false),
record: app.track().map(|t|t.1.recording).unwrap_or(false),
overdub: app.track().map(|t|t.1.overdub).unwrap_or(false),
frame: app.playhead,
quant: app.quant,
ppq: app.timebase.ppq() as usize,
bpm: app.timebase.bpm() as usize,
@ -28,14 +26,16 @@ impl TransportView {
}
}
render!(TransportView |self, buf, area| {
let Self { ppq, frame, bpm, quant, pulse, usecs, .. } = self;
let frame = *frame as f64;
let Rect { x, y, width, .. } = area;
fill_bg(buf, Rect {
x, y, width, height: if width > 100 { 1 } else { 2 }
}, Color::Rgb(20, 45, 5));
let style = Style::default().not_dim();
let mut area = Split::right([
let mut area = area;
area.height = if area.width > 100 { 1 } else { 2 };
let Self { ppq, bpm, quant, pulse, usecs, .. } = self;
fill_bg(buf, area, Color::Rgb(20, 45, 5));
let dim = Style::default().dim();
let not_dim = Style::default().not_dim();
let red = not_dim.red();
let green = not_dim.green();
let yellow = not_dim.yellow();
Split::right([
// Play/Pause button
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
@ -55,49 +55,37 @@ render!(TransportView |self, buf, area| {
// Record button/indicator
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
"⏺ REC".blit(buf, x, y, Some(if self.record {
Style::default().bold().red()
} else {
Style::default().bold().dim()
}))
"⏺ REC".blit(buf, x, y, Some(if self.record { red } else { dim }))
},
// Overdub button/indicator
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
"⏺ DUB".blit(buf, x, y, Some(if self.overdub {
Style::default().bold().yellow()
} else {
Style::default().bold().dim()
}))
"⏺ DUB".blit(buf, x, y, Some(if self.overdub { yellow } else { dim }))
},
// Monitor button/indicator
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
"⏺ MON".blit(buf, x, y, Some(if self.monitor {
Style::default().bold().green()
} else {
Style::default().bold().dim()
}))
"⏺ MON".blit(buf, x, y, Some(if self.monitor { green } else { dim }))
},
// Beats per minute
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
"BPM".blit(buf, x, y, Some(style))?;
format!("{}.{:03}", bpm, bpm % 1).blit(buf, x + 4, y, Some(style.bold()))?;
"BPM".blit(buf, x, y, Some(not_dim))?;
format!("{}.{:03}", bpm, bpm % 1).blit(buf, x + 4, y, Some(not_dim.bold()))?;
Ok(Rect { x, y, width: 13, height: 1 })
},
// Quantization
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
"QUANT".blit(buf, x, y, Some(style))?;
ppq_to_name(*quant).blit(buf, x + 6, y, Some(style.bold()))?;
"QUANT".blit(buf, x, y, Some(not_dim))?;
ppq_to_name(*quant).blit(buf, x + 6, y, Some(not_dim.bold()))?;
Ok(Rect { x, y, width: 12, height: 1 })
},
// Clip launch sync
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
"SYNC".blit(buf, x, y, Some(style))?;
"4/4".blit(buf, x + 5, y, Some(style.bold()))?;
"SYNC".blit(buf, x, y, Some(not_dim))?;
"4/4".blit(buf, x + 5, y, Some(not_dim.bold()))?;
Ok(Rect { x, y, width: 12, height: 1 })
},
@ -111,7 +99,5 @@ render!(TransportView |self, buf, area| {
timer.blit(buf, x + width - timer.len() as u16 - 1, y, Some(Style::default().not_dim()))
}
]).render(buf, area)?;
area.height = 1;
Ok(area)
]).render(buf, area)
});