mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
wip: <200 errors yay
This commit is contained in:
parent
14d619a10a
commit
694970bf0d
20 changed files with 384 additions and 305 deletions
|
|
@ -117,16 +117,7 @@ impl Tui {
|
||||||
&mut self.buffers[self.buffer]
|
&mut self.buffers[self.buffer]
|
||||||
}
|
}
|
||||||
pub fn buffer_update (&mut self, area: Rect, callback: &impl Fn(&mut Cell, u16, u16)) {
|
pub fn buffer_update (&mut self, area: Rect, callback: &impl Fn(&mut Cell, u16, u16)) {
|
||||||
let buf = self.buffer();
|
buffer_update(self.buffer(), area, callback)
|
||||||
for row in 0..area.height {
|
|
||||||
let y = area.y + row;
|
|
||||||
for col in 0..area.width {
|
|
||||||
let x = area.x + col;
|
|
||||||
if x < buf.area.width && y < buf.area.height {
|
|
||||||
callback(buf.get_mut(x, y), col, row);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
pub fn fill_bg (&mut self, area: Rect, color: Color) {
|
pub fn fill_bg (&mut self, area: Rect, color: Color) {
|
||||||
self.buffer_update(area, &|cell,_,_|{cell.set_bg(color);})
|
self.buffer_update(area, &|cell,_,_|{cell.set_bg(color);})
|
||||||
|
|
@ -628,3 +619,15 @@ impl<R: Render<Tui>> Render<Tui> for (Outset<u16>, R) {
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn buffer_update (buf: &mut Buffer, area: Rect, callback: &impl Fn(&mut Cell, u16, u16)) {
|
||||||
|
for row in 0..area.height {
|
||||||
|
let y = area.y + row;
|
||||||
|
for col in 0..area.width {
|
||||||
|
let x = area.x + col;
|
||||||
|
if x < buf.area.width && y < buf.area.height {
|
||||||
|
callback(buf.get_mut(x, y), col, row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ version = "0.1.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tek_core = { path = "../tek_core" }
|
tek_core = { path = "../tek_core" }
|
||||||
|
tek_proc = { path = "../tek_proc" }
|
||||||
|
|
||||||
livi = "0.7.4"
|
livi = "0.7.4"
|
||||||
suil-rs = { path = "../suil" }
|
suil-rs = { path = "../suil" }
|
||||||
|
|
@ -31,4 +32,4 @@ path = "src/sampler_main.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "tek_plugin"
|
name = "tek_plugin"
|
||||||
path = "src/plugin_main.rs"
|
path = "src/sampler_main.rs"
|
||||||
|
|
|
||||||
|
|
@ -25,5 +25,6 @@ submod! {
|
||||||
sample_add
|
sample_add
|
||||||
sampler
|
sampler
|
||||||
sampler_edn
|
sampler_edn
|
||||||
|
sampler_view
|
||||||
voice
|
voice
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
pub struct Mixer<E> {
|
pub struct Mixer<E: Engine> {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub tracks: Vec<Track<E>>,
|
pub tracks: Vec<Track<E>>,
|
||||||
pub selected_track: usize,
|
pub selected_track: usize,
|
||||||
pub selected_column: usize,
|
pub selected_column: usize,
|
||||||
}
|
}
|
||||||
impl<E> Mixer<E> {
|
impl<E: Engine> Mixer<E> {
|
||||||
pub fn new (name: &str) -> Usually<Self> {
|
pub fn new (name: &str) -> Usually<Self> {
|
||||||
let (client, _status) = Client::new(name, ClientOptions::NO_START_SERVER)?;
|
let (client, _status) = Client::new(name, ClientOptions::NO_START_SERVER)?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
|
|
@ -25,7 +25,7 @@ impl<E> Mixer<E> {
|
||||||
self.tracks.get(self.selected_track)
|
self.tracks.get(self.selected_track)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<E> Process for Mixer<E> {
|
impl<E: Engine> Process for Mixer<E> {
|
||||||
fn process (&mut self, _: &Client, _: &ProcessScope) -> Control {
|
fn process (&mut self, _: &Client, _: &ProcessScope) -> Control {
|
||||||
Control::Continue
|
Control::Continue
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,21 +22,20 @@ pub struct AddSampleModal {
|
||||||
|
|
||||||
exit!(AddSampleModal);
|
exit!(AddSampleModal);
|
||||||
|
|
||||||
impl<'a> Render<TuiOutput<'a>, Rect> for AddSampleModal {
|
impl Render<Tui> for AddSampleModal {
|
||||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
make_dim(to.buffer);
|
let area = to.area();
|
||||||
|
to.make_dim();
|
||||||
let area = center_box(
|
let area = center_box(
|
||||||
to.area,
|
area,
|
||||||
64.max(to.area.width.saturating_sub(8)),
|
64.max(area.width.saturating_sub(8)),
|
||||||
20.max(to.area.width.saturating_sub(8)),
|
20.max(area.width.saturating_sub(8)),
|
||||||
);
|
);
|
||||||
fill_fg(to.buffer, area, Color::Reset);
|
to.fill_fg(area, Color::Reset);
|
||||||
fill_bg(to.buffer, area, Nord::bg_lo(true, true));
|
to.fill_bg(area, Nord::bg_lo(true, true));
|
||||||
fill_char(to.buffer, area, ' ');
|
to.fill_char(area, ' ');
|
||||||
format!("{}", &self.dir.to_string_lossy())
|
to.blit(&format!("{}", &self.dir.to_string_lossy()), area.x+2, area.y+1, Some(Style::default().bold()))?;
|
||||||
.blit(to.buffer, area.x+2, area.y+1, Some(Style::default().bold()))?;
|
to.blit(&"Select sample:", area.x+2, area.y+2, Some(Style::default().bold()))?;
|
||||||
"Select sample:"
|
|
||||||
.blit(to.buffer, area.x+2, area.y+2, Some(Style::default().bold()))?;
|
|
||||||
for (i, (is_dir, name)) in self.subdirs.iter()
|
for (i, (is_dir, name)) in self.subdirs.iter()
|
||||||
.map(|path|(true, path))
|
.map(|path|(true, path))
|
||||||
.chain(self.files.iter().map(|path|(false, path)))
|
.chain(self.files.iter().map(|path|(false, path)))
|
||||||
|
|
@ -49,7 +48,7 @@ impl<'a> Render<TuiOutput<'a>, Rect> for AddSampleModal {
|
||||||
let t = if is_dir { "" } else { "" };
|
let t = if is_dir { "" } else { "" };
|
||||||
let line = format!("{t} {}", name.to_string_lossy());
|
let line = format!("{t} {}", name.to_string_lossy());
|
||||||
let line = &line[..line.len().min(area.width as usize - 4)];
|
let line = &line[..line.len().min(area.width as usize - 4)];
|
||||||
line.blit(to.buffer, area.x + 2, area.y + 3 + i as u16, Some(if i == self.cursor {
|
to.blit(&line, area.x + 2, area.y + 3 + i as u16, Some(if i == self.cursor {
|
||||||
Style::default().green()
|
Style::default().green()
|
||||||
} else {
|
} else {
|
||||||
Style::default().white()
|
Style::default().white()
|
||||||
|
|
@ -58,13 +57,14 @@ impl<'a> Render<TuiOutput<'a>, Rect> for AddSampleModal {
|
||||||
Lozenge(Style::default()).draw(to)
|
Lozenge(Style::default()).draw(to)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl Handle<Tui> for AddSampleModal {
|
||||||
handle!(AddSampleModal |self,e|{
|
fn handle (&mut self, e: &Tui) -> Usually<bool> {
|
||||||
if handle_keymap(self, e, KEYMAP_ADD_SAMPLE)? {
|
if handle_keymap(self, e, KEYMAP_ADD_SAMPLE)? {
|
||||||
return Ok(true)
|
return Ok(true)
|
||||||
}
|
}
|
||||||
Ok(true)
|
Ok(true)
|
||||||
});
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl AddSampleModal {
|
impl AddSampleModal {
|
||||||
pub fn new (
|
pub fn new (
|
||||||
|
|
|
||||||
|
|
@ -13,56 +13,20 @@ pub struct Sampler {
|
||||||
pub modal: Arc<Mutex<Option<Box<dyn Exit + Send>>>>,
|
pub modal: Arc<Mutex<Option<Box<dyn Exit + Send>>>>,
|
||||||
pub output_gain: f32
|
pub output_gain: f32
|
||||||
}
|
}
|
||||||
|
impl<E: Engine> Handle<E> for Sampler {
|
||||||
|
fn handle (&mut self, e: &E) -> Usually<E::Handled> {
|
||||||
|
handle_keymap(self, event, KEYMAP_SAMPLER)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl Render<Tui> for Sampler {
|
||||||
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
|
tui_render_sampler(self, to)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
process!(Sampler = Sampler::process);
|
process!(Sampler = Sampler::process);
|
||||||
|
|
||||||
handle!(Sampler |self, event| handle_keymap(self, event, KEYMAP_SAMPLER));
|
|
||||||
|
|
||||||
impl Render<Tui> for Sampler {
|
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
|
||||||
let Rect { x, y, height, .. } = to.area();
|
|
||||||
let style = Style::default().gray();
|
|
||||||
let title = format!(" {} ({})", self.name, self.voices.read().unwrap().len());
|
|
||||||
title.blit(to.buffer(), x+1, y, Some(style.white().bold().not_dim()))?;
|
|
||||||
let mut width = title.len() + 2;
|
|
||||||
let mut y1 = 1;
|
|
||||||
let mut j = 0;
|
|
||||||
for (note, sample) in self.mapped.iter()
|
|
||||||
.map(|(note, sample)|(Some(note), sample))
|
|
||||||
.chain(self.unmapped.iter().map(|sample|(None, sample)))
|
|
||||||
{
|
|
||||||
if y1 >= height {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
let active = j == self.cursor.0;
|
|
||||||
width = width.max(
|
|
||||||
draw_sample(to.buffer(), x, y + y1, note, &*sample.read().unwrap(), active)?
|
|
||||||
);
|
|
||||||
y1 = y1 + 1;
|
|
||||||
j = j + 1;
|
|
||||||
}
|
|
||||||
let height = ((2 + y1) as u16).min(height);
|
|
||||||
Ok(Some(Rect { x, y, width: (width as u16).min(to.area().width), height }))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw_sample (
|
|
||||||
buf: &mut Buffer, x: u16, y: u16, note: Option<&u7>, sample: &Sample, focus: bool
|
|
||||||
) -> Usually<usize> {
|
|
||||||
let style = if focus { Style::default().green() } else { Style::default() };
|
|
||||||
if focus {
|
|
||||||
"🬴".blit(buf, x+1, y, Some(style.bold()))?;
|
|
||||||
}
|
|
||||||
let label1 = format!("{:3} {:12}",
|
|
||||||
note.map(|n|n.to_string()).unwrap_or(String::default()),
|
|
||||||
sample.name);
|
|
||||||
let label2 = format!("{:>6} {:>6} +0.0",
|
|
||||||
sample.start,
|
|
||||||
sample.end);
|
|
||||||
label1.blit(buf, x+2, y, Some(style.bold()))?;
|
|
||||||
label2.blit(buf, x+3+label1.len()as u16, y, Some(style))?;
|
|
||||||
Ok(label1.len() + label2.len() + 4)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Key bindings for sampler device.
|
/// Key bindings for sampler device.
|
||||||
pub const KEYMAP_SAMPLER: &'static [KeyBinding<Sampler>] = keymap!(Sampler {
|
pub const KEYMAP_SAMPLER: &'static [KeyBinding<Sampler>] = keymap!(Sampler {
|
||||||
|
|
@ -105,7 +69,7 @@ pub const KEYMAP_SAMPLER: &'static [KeyBinding<Sampler>] = keymap!(Sampler {
|
||||||
});
|
});
|
||||||
|
|
||||||
impl Sampler {
|
impl Sampler {
|
||||||
pub fn from_edn <'e, E> (args: &[Edn<'e>]) -> Usually<JackDevice<E>> {
|
pub fn from_edn <'e, E: Engine> (args: &[Edn<'e>]) -> Usually<JackDevice<E>> {
|
||||||
let mut name = String::new();
|
let mut name = String::new();
|
||||||
let mut dir = String::new();
|
let mut dir = String::new();
|
||||||
let mut samples = BTreeMap::new();
|
let mut samples = BTreeMap::new();
|
||||||
|
|
@ -134,7 +98,7 @@ impl Sampler {
|
||||||
Self::new(&name, Some(samples))
|
Self::new(&name, Some(samples))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new <E> (
|
pub fn new <E: Engine> (
|
||||||
name: &str, mapped: Option<BTreeMap<u7, Arc<RwLock<Sample>>>>
|
name: &str, mapped: Option<BTreeMap<u7, Arc<RwLock<Sample>>>>
|
||||||
) -> Usually<JackDevice<E>> {
|
) -> Usually<JackDevice<E>> {
|
||||||
Jack::new(name)?
|
Jack::new(name)?
|
||||||
|
|
|
||||||
45
crates/tek_mixer/src/sampler_view.rs
Normal file
45
crates/tek_mixer/src/sampler_view.rs
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
use crate::*;
|
||||||
|
|
||||||
|
pub fn tui_render_sampler (sampler: &Sampler, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
|
let Rect { x, y, height, .. } = to.area();
|
||||||
|
let style = Style::default().gray();
|
||||||
|
let title = format!(" {} ({})", sampler.name, sampler.voices.read().unwrap().len());
|
||||||
|
to.blit(&title, x+1, y, Some(style.white().bold().not_dim()))?;
|
||||||
|
let mut width = title.len() + 2;
|
||||||
|
let mut y1 = 1;
|
||||||
|
let mut j = 0;
|
||||||
|
for (note, sample) in sampler.mapped.iter()
|
||||||
|
.map(|(note, sample)|(Some(note), sample))
|
||||||
|
.chain(sampler.unmapped.iter().map(|sample|(None, sample)))
|
||||||
|
{
|
||||||
|
if y1 >= height {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
let active = j == sampler.cursor.0;
|
||||||
|
width = width.max(
|
||||||
|
draw_sample(to, x, y + y1, note, &*sample.read().unwrap(), active)?
|
||||||
|
);
|
||||||
|
y1 = y1 + 1;
|
||||||
|
j = j + 1;
|
||||||
|
}
|
||||||
|
let height = ((2 + y1) as u16).min(height);
|
||||||
|
Ok(Some(Rect { x, y, width: (width as u16).min(to.area().width), height }))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn draw_sample (
|
||||||
|
to: &mut Tui, x: u16, y: u16, note: Option<&u7>, sample: &Sample, focus: bool
|
||||||
|
) -> Usually<usize> {
|
||||||
|
let style = if focus { Style::default().green() } else { Style::default() };
|
||||||
|
if focus {
|
||||||
|
to.blit(&"🬴", x+1, y, Some(style.bold()))?;
|
||||||
|
}
|
||||||
|
let label1 = format!("{:3} {:12}",
|
||||||
|
note.map(|n|n.to_string()).unwrap_or(String::default()),
|
||||||
|
sample.name);
|
||||||
|
let label2 = format!("{:>6} {:>6} +0.0",
|
||||||
|
sample.start,
|
||||||
|
sample.end);
|
||||||
|
to.blit(&label1, x+2, y, Some(style.bold()))?;
|
||||||
|
to.blit(&label2, x+3+label1.len()as u16, y, Some(style))?;
|
||||||
|
Ok(label1.len() + label2.len() + 4)
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
use tek_core::Direction;
|
use tek_core::Direction;
|
||||||
|
|
||||||
impl<'a> Render<Tui> for Track<Tui> {
|
impl Render<Tui> for Track<Tui> {
|
||||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
TrackView {
|
TrackView {
|
||||||
chain: Some(&self),
|
chain: Some(&self),
|
||||||
direction: tek_core::Direction::Right,
|
direction: tek_core::Direction::Right,
|
||||||
|
|
@ -24,8 +24,8 @@ impl<'a> Render<Tui> for Track<Tui> {
|
||||||
}.render(to)
|
}.render(to)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub struct TrackView<'a, T, U> {
|
pub struct TrackView<'a, E: Engine> {
|
||||||
pub chain: Option<&'a Track<T, U>>,
|
pub chain: Option<&'a Track<E>>,
|
||||||
pub direction: Direction,
|
pub direction: Direction,
|
||||||
pub focused: bool,
|
pub focused: bool,
|
||||||
pub entered: bool,
|
pub entered: bool,
|
||||||
|
|
|
||||||
11
crates/tek_proc/Cargo.toml
Normal file
11
crates/tek_proc/Cargo.toml
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
[package]
|
||||||
|
name = "tek_proc"
|
||||||
|
edition = "2021"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
proc-macro = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
syn = { version = "2.0", features = ["full"] }
|
||||||
|
quote = "1.0"
|
||||||
18
crates/tek_proc/src/lib.rs
Normal file
18
crates/tek_proc/src/lib.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
use proc_macro::TokenStream;
|
||||||
|
use syn::{parse_macro_input, Attribute, Meta};
|
||||||
|
|
||||||
|
#[proc_macro_attribute]
|
||||||
|
pub fn render (attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||||
|
println!("attr: \"{attr}\"");
|
||||||
|
println!("item: \"{item}\"");
|
||||||
|
let input = syn::parse_macro_input!(attr as Meta);
|
||||||
|
panic!("attr: \"{input:?}\"");
|
||||||
|
item
|
||||||
|
}
|
||||||
|
|
||||||
|
#[proc_macro_attribute]
|
||||||
|
pub fn handle (attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||||
|
println!("attr: \"{attr}\"");
|
||||||
|
println!("item: \"{item}\"");
|
||||||
|
item
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,7 @@ version = "0.1.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tek_core = { path = "../tek_core" }
|
tek_core = { path = "../tek_core" }
|
||||||
|
tek_proc = { path = "../tek_proc" }
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ impl ArrangerViewMode {
|
||||||
}
|
}
|
||||||
/// Render arranger to terminal
|
/// Render arranger to terminal
|
||||||
impl Render<Tui> for Arranger<Tui> {
|
impl Render<Tui> for Arranger<Tui> {
|
||||||
fn render (&'a self, to: &'a mut TuiOutput<'a>) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
let area = (|to|match self.mode {
|
let area = (|to|match self.mode {
|
||||||
ArrangerViewMode::Horizontal =>
|
ArrangerViewMode::Horizontal =>
|
||||||
super::arranger_view_h::draw(self, to),
|
super::arranger_view_h::draw(self, to),
|
||||||
|
|
@ -111,18 +111,19 @@ impl Render<Tui> for Arranger<Tui> {
|
||||||
super::arranger_view_v::draw_compact_2(self, to),
|
super::arranger_view_v::draw_compact_2(self, to),
|
||||||
ArrangerViewMode::VerticalExpanded =>
|
ArrangerViewMode::VerticalExpanded =>
|
||||||
super::arranger_view_v::draw_expanded(self, to),
|
super::arranger_view_v::draw_expanded(self, to),
|
||||||
})(&mut to.area(Rect {
|
})(&mut to.alter_area(|x, y, w, h|(
|
||||||
x: to.area.x + 1,
|
x + 1,
|
||||||
width: to.area.width - 2,
|
y + 1,
|
||||||
y: to.area.y + 1,
|
w.saturating_sub(2),
|
||||||
height: to.area.height - 2
|
h.saturating_sub(2),
|
||||||
}))?.unwrap();
|
)))?.unwrap();
|
||||||
Lozenge(Style::default().fg(Nord::BG2)).draw(&mut to.area(Rect {
|
Lozenge(Style::default().fg(Nord::BG2))
|
||||||
x: area.x.saturating_sub(1),
|
.draw(&mut to.alter_area(|x, y, w, h|(
|
||||||
width: area.width + 2,
|
x.saturating_sub(1),
|
||||||
y: area.y.saturating_sub(1),
|
y.saturating_sub(1),
|
||||||
height: area.height + 2,
|
w + 2,
|
||||||
}))
|
h + 2,
|
||||||
|
)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Focusable<Tui> for Arranger<Tui> {
|
impl Focusable<Tui> for Arranger<Tui> {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
impl<'a> Arranger<TuiOutput<'a>, Rect> {
|
impl<'a> Arranger<Tui> {
|
||||||
pub fn rename_selected (&mut self) {
|
pub fn rename_selected (&mut self) {
|
||||||
self.modal = Some(Box::new(ArrangerRenameModal::new(
|
self.modal = Some(Box::new(ArrangerRenameModal::new(
|
||||||
self.selected,
|
self.selected,
|
||||||
|
|
@ -31,16 +31,17 @@ impl ArrangerRenameModal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<'a> Render<TuiOutput<'a>, Rect> for ArrangerRenameModal {
|
impl Render<Tui> for ArrangerRenameModal {
|
||||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
let y = to.area.y + to.area.height / 2;
|
let area = to.area();
|
||||||
|
let y = area.y + area.height / 2;
|
||||||
let bg_area = Rect {
|
let bg_area = Rect {
|
||||||
x: 1,
|
x: 1,
|
||||||
y: y - 1,
|
y: y - 1,
|
||||||
width: to.area.width - 2,
|
width: area.width - 2,
|
||||||
height: 3
|
height: 3
|
||||||
};
|
};
|
||||||
fill_bg(to.buffer, bg_area, Nord::BG0);
|
to.fill_bg(bg_area, Nord::BG0);
|
||||||
Lozenge(Style::default().bold().white().dim()).draw(to.buffer, bg_area)?;
|
Lozenge(Style::default().bold().white().dim()).draw(to.buffer, bg_area)?;
|
||||||
let label = match self.target {
|
let label = match self.target {
|
||||||
ArrangerFocus::Mix => "Rename project:",
|
ArrangerFocus::Mix => "Rename project:",
|
||||||
|
|
@ -49,15 +50,16 @@ impl<'a> Render<TuiOutput<'a>, Rect> for ArrangerRenameModal {
|
||||||
ArrangerFocus::Clip(_, _) => "Rename clip:",
|
ArrangerFocus::Clip(_, _) => "Rename clip:",
|
||||||
};
|
};
|
||||||
let style = Some(Style::default().not_bold().white().not_dim());
|
let style = Some(Style::default().not_bold().white().not_dim());
|
||||||
label.blit(to.buffer, to.area.x + 3, y, style)?;
|
to.blit(&label, area.x + 3, y, style)?;
|
||||||
let style = Some(Style::default().bold().white().not_dim());
|
let style = Some(Style::default().bold().white().not_dim());
|
||||||
self.value.blit(to.buffer, to.area.x + 3 + label.len() as u16 + 1, y, style)?;
|
to.blit(&self.value, area.x + 3 + label.len() as u16 + 1, y, style)?;
|
||||||
let style = Some(Style::default().bold().white().not_dim().reversed());
|
let style = Some(Style::default().bold().white().not_dim().reversed());
|
||||||
"▂".blit(to.buffer, to.area.x + 3 + label.len() as u16 + 1 + self.cursor as u16, y, style)?;
|
to.blit(&"▂", area.x + 3 + label.len() as u16 + 1 + self.cursor as u16, y, style)?;
|
||||||
Ok(Some(to.area))
|
Ok(Some(area))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handle!(ArrangerRenameModal |self, e| {
|
impl Handle<Tui> for TransportQuantize {
|
||||||
|
fn handle (&mut self, from: &Tui) -> Perhaps<bool> {
|
||||||
match e {
|
match e {
|
||||||
AppEvent::Input(Event::Key(k)) => {
|
AppEvent::Input(Event::Key(k)) => {
|
||||||
match k.code {
|
match k.code {
|
||||||
|
|
@ -92,7 +94,8 @@ handle!(ArrangerRenameModal |self, e| {
|
||||||
},
|
},
|
||||||
_ => Ok(false),
|
_ => Ok(false),
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
}
|
||||||
impl Exit for ArrangerRenameModal {
|
impl Exit for ArrangerRenameModal {
|
||||||
fn exited (&self) -> bool {
|
fn exited (&self) -> bool {
|
||||||
self.done
|
self.done
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
pub fn draw <'a> (
|
pub fn draw (state: &Arranger<Tui>, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
state: &Arranger<TuiOutput<'a>, Rect>, to: &mut TuiOutput<'a>
|
let mut area = to.area();
|
||||||
) -> Perhaps<Rect> {
|
|
||||||
let mut area = to.area;
|
|
||||||
area.height = area.height.min((2 + state.tracks.len() * 2) as u16);
|
area.height = area.height.min((2 + state.tracks.len() * 2) as u16);
|
||||||
let tracks = state.tracks.as_slice();
|
let tracks = state.tracks.as_slice();
|
||||||
Layered::new()
|
Layered::new()
|
||||||
|
|
@ -21,10 +19,10 @@ pub fn draw <'a> (
|
||||||
|
|
||||||
struct TrackNameColumn<'a>(&'a [Sequencer], ArrangerFocus);
|
struct TrackNameColumn<'a>(&'a [Sequencer], ArrangerFocus);
|
||||||
|
|
||||||
impl<'a> Render<TuiOutput<'a>, Rect> for TrackNameColumn<'a> {
|
impl<'a> Render<Tui> for TrackNameColumn<'a> {
|
||||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
let Self(tracks, selected) = self;
|
let Self(tracks, selected) = self;
|
||||||
let mut area = to.area;
|
let mut area = to.area();
|
||||||
let yellow = Some(Style::default().yellow().bold().not_dim());
|
let yellow = Some(Style::default().yellow().bold().not_dim());
|
||||||
let white = Some(Style::default().white().bold().not_dim());
|
let white = Some(Style::default().white().bold().not_dim());
|
||||||
area.width = 3 + 5.max(track_name_max_len(tracks)) as u16;
|
area.width = 3 + 5.max(track_name_max_len(tracks)) as u16;
|
||||||
|
|
@ -48,10 +46,10 @@ impl<'a> Render<TuiOutput<'a>, Rect> for TrackNameColumn<'a> {
|
||||||
|
|
||||||
struct TrackMonitorColumn<'a>(&'a [Sequencer]);
|
struct TrackMonitorColumn<'a>(&'a [Sequencer]);
|
||||||
|
|
||||||
impl<'a> Render<TuiOutput<'a>, Rect> for TrackMonitorColumn<'a> {
|
impl<'a> Render<Tui> for TrackMonitorColumn<'a> {
|
||||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
let Self(tracks) = self;
|
let Self(tracks) = self;
|
||||||
let mut area = to.area;
|
let mut area = to.area();
|
||||||
let on = Some(Style::default().not_dim().green().bold());
|
let on = Some(Style::default().not_dim().green().bold());
|
||||||
let off = Some(DIM);
|
let off = Some(DIM);
|
||||||
area.x += 1;
|
area.x += 1;
|
||||||
|
|
@ -76,10 +74,10 @@ impl<'a> Render<TuiOutput<'a>, Rect> for TrackMonitorColumn<'a> {
|
||||||
|
|
||||||
struct TrackRecordColumn<'a>(&'a [Sequencer]);
|
struct TrackRecordColumn<'a>(&'a [Sequencer]);
|
||||||
|
|
||||||
impl<'a> Render<TuiOutput<'a>, Rect> for TrackRecordColumn<'a> {
|
impl<'a> Render<Tui> for TrackRecordColumn<'a> {
|
||||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
let Self(tracks) = self;
|
let Self(tracks) = self;
|
||||||
let mut area = to.area;
|
let mut area = to.area();
|
||||||
let on = Some(Style::default().not_dim().red().bold());
|
let on = Some(Style::default().not_dim().red().bold());
|
||||||
let off = Some(Style::default().dim());
|
let off = Some(Style::default().dim());
|
||||||
area.x += 1;
|
area.x += 1;
|
||||||
|
|
@ -104,10 +102,10 @@ impl<'a> Render<TuiOutput<'a>, Rect> for TrackRecordColumn<'a> {
|
||||||
|
|
||||||
struct TrackOverdubColumn<'a>(&'a [Sequencer]);
|
struct TrackOverdubColumn<'a>(&'a [Sequencer]);
|
||||||
|
|
||||||
impl<'a> Render<TuiOutput<'a>, Rect> for TrackOverdubColumn<'a> {
|
impl<'a> Render<Tui> for TrackOverdubColumn<'a> {
|
||||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
let Self(tracks) = self;
|
let Self(tracks) = self;
|
||||||
let mut area = to.area;
|
let mut area = to.area();
|
||||||
let on = Some(Style::default().not_dim().yellow().bold());
|
let on = Some(Style::default().not_dim().yellow().bold());
|
||||||
let off = Some(Style::default().dim());
|
let off = Some(Style::default().dim());
|
||||||
area.x = area.x + 1;
|
area.x = area.x + 1;
|
||||||
|
|
@ -135,10 +133,10 @@ impl<'a> Render<TuiOutput<'a>, Rect> for TrackOverdubColumn<'a> {
|
||||||
|
|
||||||
struct TrackEraseColumn<'a>(&'a [Sequencer]);
|
struct TrackEraseColumn<'a>(&'a [Sequencer]);
|
||||||
|
|
||||||
impl<'a> Render<TuiOutput<'a>, Rect> for TrackEraseColumn<'a> {
|
impl<'a> Render<Tui> for TrackEraseColumn<'a> {
|
||||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
let Self(tracks) = self;
|
let Self(tracks) = self;
|
||||||
let mut area = to.area;
|
let mut area = to.area();
|
||||||
let off = Some(Style::default().dim());
|
let off = Some(Style::default().dim());
|
||||||
area.x = area.x + 1;
|
area.x = area.x + 1;
|
||||||
for y in 0..area.height {
|
for y in 0..area.height {
|
||||||
|
|
@ -147,7 +145,7 @@ impl<'a> Render<TuiOutput<'a>, Rect> for TrackEraseColumn<'a> {
|
||||||
} else if y % 2 == 0 {
|
} else if y % 2 == 0 {
|
||||||
let index = (y as usize - 2) / 2;
|
let index = (y as usize - 2) / 2;
|
||||||
if let Some(_) = tracks.get(index) {
|
if let Some(_) = tracks.get(index) {
|
||||||
" DEL ".blit(to.buffer, area.x, area.y + y, off)?;
|
to.blit(&" DEL ", area.x, area.y + y, off)?;
|
||||||
} else {
|
} else {
|
||||||
area.height = y;
|
area.height = y;
|
||||||
break
|
break
|
||||||
|
|
@ -161,10 +159,10 @@ impl<'a> Render<TuiOutput<'a>, Rect> for TrackEraseColumn<'a> {
|
||||||
|
|
||||||
struct TrackGainColumn<'a>(&'a [Sequencer]);
|
struct TrackGainColumn<'a>(&'a [Sequencer]);
|
||||||
|
|
||||||
impl<'a> Render<TuiOutput<'a>, Rect> for TrackGainColumn<'a> {
|
impl<'a> Render<Tui> for TrackGainColumn<'a> {
|
||||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
let Self(tracks) = self;
|
let Self(tracks) = self;
|
||||||
let mut area = to.area;
|
let mut area = to.area();
|
||||||
let off = Some(Style::default().dim());
|
let off = Some(Style::default().dim());
|
||||||
area.x = area.x + 1;
|
area.x = area.x + 1;
|
||||||
for y in 0..area.height {
|
for y in 0..area.height {
|
||||||
|
|
@ -173,7 +171,7 @@ impl<'a> Render<TuiOutput<'a>, Rect> for TrackGainColumn<'a> {
|
||||||
} else if y % 2 == 0 {
|
} else if y % 2 == 0 {
|
||||||
let index = (y as usize - 2) / 2;
|
let index = (y as usize - 2) / 2;
|
||||||
if let Some(_) = tracks.get(index) {
|
if let Some(_) = tracks.get(index) {
|
||||||
" +0.0 ".blit(to.buffer, area.x, area.y + y, off)?;
|
to.blit(&" +0.0 ", area.x, area.y + y, off)?;
|
||||||
} else {
|
} else {
|
||||||
area.height = y;
|
area.height = y;
|
||||||
break
|
break
|
||||||
|
|
@ -187,10 +185,10 @@ impl<'a> Render<TuiOutput<'a>, Rect> for TrackGainColumn<'a> {
|
||||||
|
|
||||||
struct TrackScenesColumn<'a>(&'a [Sequencer], &'a [Scene], ArrangerFocus);
|
struct TrackScenesColumn<'a>(&'a [Sequencer], &'a [Scene], ArrangerFocus);
|
||||||
|
|
||||||
impl<'a> Render<TuiOutput<'a>, Rect> for TrackScenesColumn<'a> {
|
impl<'a> Render<Tui> for TrackScenesColumn<'a> {
|
||||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
let Self(tracks, scenes, selected) = self;
|
let Self(tracks, scenes, selected) = self;
|
||||||
let area = to.area;
|
let area = to.area();
|
||||||
let mut x2 = 0;
|
let mut x2 = 0;
|
||||||
let Rect { x, y, height, .. } = area;
|
let Rect { x, y, height, .. } = area;
|
||||||
for (scene_index, scene) in scenes.iter().enumerate() {
|
for (scene_index, scene) in scenes.iter().enumerate() {
|
||||||
|
|
@ -201,11 +199,11 @@ impl<'a> Render<TuiOutput<'a>, Rect> for TrackScenesColumn<'a> {
|
||||||
Style::default().dim()
|
Style::default().dim()
|
||||||
});
|
});
|
||||||
for y in y+1..y+height {
|
for y in y+1..y+height {
|
||||||
"│".blit(to.buffer, x + x2, y, sep)?;
|
to.blit(&"│", x + x2, y, sep)?;
|
||||||
}
|
}
|
||||||
let name = scene.name.read().unwrap();
|
let name = scene.name.read().unwrap();
|
||||||
let mut x3 = name.len() as u16;
|
let mut x3 = name.len() as u16;
|
||||||
name.blit(to.buffer, x + x2, y, sep)?;
|
to.blit(&name, x + x2, y, sep)?;
|
||||||
for (i, clip) in scene.clips.iter().enumerate() {
|
for (i, clip) in scene.clips.iter().enumerate() {
|
||||||
let active_track = selected.track() == Some(i);
|
let active_track = selected.track() == Some(i);
|
||||||
if let Some(clip) = clip {
|
if let Some(clip) = clip {
|
||||||
|
|
@ -214,7 +212,7 @@ impl<'a> Render<TuiOutput<'a>, Rect> for TrackScenesColumn<'a> {
|
||||||
Some(phrase) => &format!("{}", phrase.read().unwrap().name.read().unwrap()),
|
Some(phrase) => &format!("{}", phrase.read().unwrap().name.read().unwrap()),
|
||||||
None => "...."
|
None => "...."
|
||||||
};
|
};
|
||||||
label.blit(to.buffer, x + x2, y2, Some(if active_track && active_scene {
|
to.blit(&label, x + x2, y2, Some(if active_track && active_scene {
|
||||||
Style::default().not_dim().yellow().bold()
|
Style::default().not_dim().yellow().bold()
|
||||||
} else {
|
} else {
|
||||||
Style::default().not_dim()
|
Style::default().not_dim()
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
handle!(Sequencer |self, e| handle_keymap(self, e, KEYMAP_SEQUENCER));
|
impl Handle<Tui> for TransportQuantize {
|
||||||
|
fn handle (&mut self, from: &Tui) -> Perhaps<bool> {
|
||||||
|
handle_keymap(self, e, KEYMAP_SEQUENCER)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Key bindings for phrase editor.
|
/// Key bindings for phrase editor.
|
||||||
pub const KEYMAP_SEQUENCER: &'static [KeyBinding<Sequencer>] = keymap!(Sequencer {
|
pub const KEYMAP_SEQUENCER: &'static [KeyBinding<Sequencer>] = keymap!(Sequencer {
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
impl<'a> Render<TuiOutput<'a>, Rect> for Sequencer {
|
impl<'a> Render<Tui> for Sequencer {
|
||||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
self.horizontal_draw(to)?;
|
self.horizontal_draw(to)?;
|
||||||
if self.focused && self.entered {
|
if self.focused && self.entered {
|
||||||
Corners(Style::default().green().not_dim()).draw(to.buffer, to.area)?;
|
Corners(Style::default().green().not_dim()).draw(to)?;
|
||||||
}
|
}
|
||||||
Ok(Some(to.area))
|
Ok(Some(to.area()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ impl Sequencer {
|
||||||
|
|
||||||
const H_KEYS_OFFSET: usize = 5;
|
const H_KEYS_OFFSET: usize = 5;
|
||||||
|
|
||||||
pub(crate) fn horizontal_draw <'a> (&self, to: &mut TuiOutput<'a>) -> Usually<()> {
|
pub(crate) fn horizontal_draw <'a> (&self, to: &mut Tui) -> Usually<()> {
|
||||||
let mut area = to.area;
|
let mut area = to.area();
|
||||||
Split::down()
|
Split::down()
|
||||||
.add_ref(&SequenceName(&self))
|
.add_ref(&SequenceName(&self))
|
||||||
.add_ref(&SequenceRange)
|
.add_ref(&SequenceRange)
|
||||||
|
|
@ -32,7 +32,10 @@ impl Sequencer {
|
||||||
.add_ref(&SequenceNotes(&self))
|
.add_ref(&SequenceNotes(&self))
|
||||||
.add_ref(&SequenceCursor(&self))
|
.add_ref(&SequenceCursor(&self))
|
||||||
.add_ref(&SequenceZoom(&self))
|
.add_ref(&SequenceZoom(&self))
|
||||||
.render(&mut TuiOutput { buffer: to.buffer, area: area })?;
|
.render(&mut TuiOutput {
|
||||||
|
buffer: to.buffer,
|
||||||
|
area: area
|
||||||
|
})?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -56,9 +59,9 @@ const STYLE_VALUE: Option<Style> = Some(Style {
|
||||||
|
|
||||||
struct SequenceName<'a>(&'a Sequencer);
|
struct SequenceName<'a>(&'a Sequencer);
|
||||||
|
|
||||||
impl<'a> Render<TuiOutput<'a>, Rect> for SequenceName<'a> {
|
impl<'a> Render<Tui> for SequenceName<'a> {
|
||||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
let Rect { x, y, .. } = to.area;
|
let Rect { x, y, .. } = to.area();
|
||||||
let frame = Rect { x, y, width: 10, height: 4 };
|
let frame = Rect { x, y, width: 10, height: 4 };
|
||||||
Lozenge(Style::default().fg(Nord::BG2)).draw(to.buffer, frame)?;
|
Lozenge(Style::default().fg(Nord::BG2)).draw(to.buffer, frame)?;
|
||||||
"Name:".blit(to.buffer, x + 1, y + 1, STYLE_LABEL)?;
|
"Name:".blit(to.buffer, x + 1, y + 1, STYLE_LABEL)?;
|
||||||
|
|
@ -69,9 +72,9 @@ impl<'a> Render<TuiOutput<'a>, Rect> for SequenceName<'a> {
|
||||||
|
|
||||||
struct SequenceRange;
|
struct SequenceRange;
|
||||||
|
|
||||||
impl<'a> Render<TuiOutput<'a>, Rect> for SequenceRange {
|
impl<'a> Render<Tui> for SequenceRange {
|
||||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
let Rect { x, y, .. } = to.area;
|
let Rect { x, y, .. } = to.area();
|
||||||
let frame = Rect { x, y, width: 10, height: 6 };
|
let frame = Rect { x, y, width: 10, height: 6 };
|
||||||
Lozenge(Style::default().fg(Nord::BG2)).draw(to.buffer, frame)?;
|
Lozenge(Style::default().fg(Nord::BG2)).draw(to.buffer, frame)?;
|
||||||
"Start: ".blit(to.buffer, x + 1, y + 1, STYLE_LABEL)?;
|
"Start: ".blit(to.buffer, x + 1, y + 1, STYLE_LABEL)?;
|
||||||
|
|
@ -84,9 +87,9 @@ impl<'a> Render<TuiOutput<'a>, Rect> for SequenceRange {
|
||||||
|
|
||||||
struct SequenceLoopRange;
|
struct SequenceLoopRange;
|
||||||
|
|
||||||
impl<'a> Render<TuiOutput<'a>, Rect> for SequenceLoopRange {
|
impl<'a> Render<Tui> for SequenceLoopRange {
|
||||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
let Rect { x, y, .. } = to.area;
|
let Rect { x, y, .. } = to.area();
|
||||||
let range = Rect { x, y, width: 10, height: 7 };
|
let range = Rect { x, y, width: 10, height: 7 };
|
||||||
Lozenge(Style::default().fg(Nord::BG2)).draw(to.buffer, range)?;
|
Lozenge(Style::default().fg(Nord::BG2)).draw(to.buffer, range)?;
|
||||||
"Loop [ ]".blit(to.buffer, x + 1, y + 1, STYLE_LABEL)?;
|
"Loop [ ]".blit(to.buffer, x + 1, y + 1, STYLE_LABEL)?;
|
||||||
|
|
@ -100,9 +103,9 @@ impl<'a> Render<TuiOutput<'a>, Rect> for SequenceLoopRange {
|
||||||
|
|
||||||
struct SequenceNoteRange;
|
struct SequenceNoteRange;
|
||||||
|
|
||||||
impl<'a> Render<TuiOutput<'a>, Rect> for SequenceNoteRange {
|
impl<'a> Render<Tui> for SequenceNoteRange {
|
||||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
let Rect { x, y, .. } = to.area;
|
let Rect { x, y, .. } = to.area();
|
||||||
let range = Rect { x, y, width: 10, height: 9 };
|
let range = Rect { x, y, width: 10, height: 9 };
|
||||||
Lozenge(Style::default().fg(Nord::BG2)).draw(to.buffer, range)?;
|
Lozenge(Style::default().fg(Nord::BG2)).draw(to.buffer, range)?;
|
||||||
"Notes: ".blit(to.buffer, x + 1, y + 1, STYLE_LABEL)?;
|
"Notes: ".blit(to.buffer, x + 1, y + 1, STYLE_LABEL)?;
|
||||||
|
|
@ -118,8 +121,8 @@ impl<'a> Render<TuiOutput<'a>, Rect> for SequenceNoteRange {
|
||||||
|
|
||||||
struct SequenceKeys<'a>(&'a Sequencer);
|
struct SequenceKeys<'a>(&'a Sequencer);
|
||||||
|
|
||||||
impl<'a> Render<TuiOutput<'a>, Rect> for SequenceKeys<'a> {
|
impl<'a> Render<Tui> for SequenceKeys<'a> {
|
||||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
if to.area.height < 2 {
|
if to.area.height < 2 {
|
||||||
return Ok(Some(to.area))
|
return Ok(Some(to.area))
|
||||||
}
|
}
|
||||||
|
|
@ -141,18 +144,19 @@ impl<'a> Render<TuiOutput<'a>, Rect> for SequenceKeys<'a> {
|
||||||
|
|
||||||
struct SequenceNotes<'a>(&'a Sequencer);
|
struct SequenceNotes<'a>(&'a Sequencer);
|
||||||
|
|
||||||
impl<'a> Render<TuiOutput<'a>, Rect> for SequenceNotes<'a> {
|
impl<'a> Render<Tui> for SequenceNotes<'a> {
|
||||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
if to.area.height < 2 {
|
let area = to.area();
|
||||||
return Ok(Some(to.area))
|
if area.height < 2 {
|
||||||
|
return Ok(Some(area))
|
||||||
}
|
}
|
||||||
let area = Rect {
|
let area = Rect {
|
||||||
x: to.area.x + Sequencer::H_KEYS_OFFSET as u16,
|
x: area.x + Sequencer::H_KEYS_OFFSET as u16,
|
||||||
y: to.area.y + 1,
|
y: area.y + 1,
|
||||||
width: to.area.width - Sequencer::H_KEYS_OFFSET as u16,
|
width: area.width - Sequencer::H_KEYS_OFFSET as u16,
|
||||||
height: to.area.height - 2
|
height: area.height - 2
|
||||||
};
|
};
|
||||||
buffer_update(to.buffer, area, &move |cell, x, y|{
|
to.buffer_update(area, &move |cell, x, y|{
|
||||||
let src_x = ((x as usize + self.0.time_axis.start) * self.0.time_axis.scale) as usize;
|
let src_x = ((x as usize + self.0.time_axis.start) * self.0.time_axis.scale) as usize;
|
||||||
let src_y = (y as usize + self.0.note_axis.start) as usize;
|
let src_y = (y as usize + self.0.note_axis.start) as usize;
|
||||||
if src_x < self.0.buffer.width && src_y < self.0.buffer.height - 1 {
|
if src_x < self.0.buffer.width && src_y < self.0.buffer.height - 1 {
|
||||||
|
|
@ -163,19 +167,20 @@ impl<'a> Render<TuiOutput<'a>, Rect> for SequenceNotes<'a> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Ok(Some(to.area))
|
Ok(Some(area))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SequenceCursor<'a>(&'a Sequencer);
|
struct SequenceCursor<'a>(&'a Sequencer);
|
||||||
|
|
||||||
impl<'a> Render<TuiOutput<'a>, Rect> for SequenceCursor<'a> {
|
impl<'a> Render<Tui> for SequenceCursor<'a> {
|
||||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
|
let area = to.area();
|
||||||
if let (Some(time), Some(note)) = (self.0.time_axis.point, self.0.note_axis.point) {
|
if let (Some(time), Some(note)) = (self.0.time_axis.point, self.0.note_axis.point) {
|
||||||
let x = to.area.x + Sequencer::H_KEYS_OFFSET as u16 + time as u16;
|
let x = area.x + Sequencer::H_KEYS_OFFSET as u16 + time as u16;
|
||||||
let y = to.area.y + 1 + note as u16 / 2;
|
let y = area.y + 1 + note as u16 / 2;
|
||||||
let c = if note % 2 == 0 { "▀" } else { "▄" };
|
let c = if note % 2 == 0 { "▀" } else { "▄" };
|
||||||
c.blit(to.buffer, x, y, self.0.style_focus())
|
to.blit(&c, x, y, self.0.style_focus())
|
||||||
} else {
|
} else {
|
||||||
Ok(Some(Rect::default()))
|
Ok(Some(Rect::default()))
|
||||||
}
|
}
|
||||||
|
|
@ -184,32 +189,34 @@ impl<'a> Render<TuiOutput<'a>, Rect> for SequenceCursor<'a> {
|
||||||
|
|
||||||
struct SequenceZoom<'a>(&'a Sequencer);
|
struct SequenceZoom<'a>(&'a Sequencer);
|
||||||
|
|
||||||
impl<'a> Render<TuiOutput<'a>, Rect> for SequenceZoom<'a> {
|
impl<'a> Render<Tui> for SequenceZoom<'a> {
|
||||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
|
let area = to.area();
|
||||||
let quant = ppq_to_name(self.0.time_axis.scale);
|
let quant = ppq_to_name(self.0.time_axis.scale);
|
||||||
let quant_x = to.area.x + to.area.width - 1 - quant.len() as u16;
|
let quant_x = area.x + area.width - 1 - quant.len() as u16;
|
||||||
let quant_y = to.area.y + to.area.height - 2;
|
let quant_y = area.y + area.height - 2;
|
||||||
quant.blit(to.buffer, quant_x, quant_y, self.0.style_focus())
|
buffer.blit(&quant, quant_x, quant_y, self.0.style_focus())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SequenceTimer<'a>(&'a Sequencer, Arc<RwLock<Phrase>>);
|
struct SequenceTimer<'a>(&'a Sequencer, Arc<RwLock<Phrase>>);
|
||||||
|
|
||||||
impl<'a> Render<TuiOutput<'a>, Rect> for SequenceTimer<'a> {
|
impl<'a> Render<Tui> for SequenceTimer<'a> {
|
||||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
|
let area = to.area();
|
||||||
let phrase = self.1.read().unwrap();
|
let phrase = self.1.read().unwrap();
|
||||||
let (time0, time_z, now) = (
|
let (time0, time_z, now) = (
|
||||||
self.0.time_axis.start, self.0.time_axis.scale, self.0.now % phrase.length
|
self.0.time_axis.start, self.0.time_axis.scale, self.0.now % phrase.length
|
||||||
);
|
);
|
||||||
let Rect { x, width, .. } = to.area;
|
let Rect { x, width, .. } = area;
|
||||||
let x2 = x as usize + Sequencer::H_KEYS_OFFSET;
|
let x2 = x as usize + Sequencer::H_KEYS_OFFSET;
|
||||||
let x3 = x as usize + width as usize;
|
let x3 = x as usize + width as usize;
|
||||||
for x in x2..x3 {
|
for x in x2..x3 {
|
||||||
let step = (time0 + x2) * time_z;
|
let step = (time0 + x2) * time_z;
|
||||||
let next_step = (time0 + x2 + 1) * time_z;
|
let next_step = (time0 + x2 + 1) * time_z;
|
||||||
let style = Sequencer::style_timer_step(now, step as usize, next_step as usize);
|
let style = Sequencer::style_timer_step(now, step as usize, next_step as usize);
|
||||||
"-".blit(to.buffer, x as u16, to.area.y, Some(style))?;
|
to.blit(&"-", x as u16, area.y, Some(style))?;
|
||||||
}
|
}
|
||||||
return Ok(Some(Rect { x: to.area.x, y: to.area.y, width: to.area.width, height: 1 }))
|
return Ok(Some(Rect { x: area.x, y: area.y, width: area.width, height: 1 }))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -142,33 +142,33 @@ impl TransportToolbar {
|
||||||
self.timebase.frame_to_usec(self.clock.frame as f64) as usize
|
self.timebase.frame_to_usec(self.clock.frame as f64) as usize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<'a> Focus<5, TuiOutput<'a>, Rect> for TransportToolbar {
|
impl Focus<5, Tui> for TransportToolbar {
|
||||||
fn focus (&self) -> usize {
|
fn focus (&self) -> usize {
|
||||||
self.focus
|
self.focus
|
||||||
}
|
}
|
||||||
fn focus_mut (&mut self) -> &mut usize {
|
fn focus_mut (&mut self) -> &mut usize {
|
||||||
&mut self.focus
|
&mut self.focus
|
||||||
}
|
}
|
||||||
fn focusable (&self) -> [&dyn Focusable<TuiOutput<'a>, Rect>;5] {
|
fn focusable (&self) -> [&dyn Focusable<Tui>;5] {
|
||||||
[
|
[
|
||||||
&self.playing as &dyn Focusable<TuiOutput<'a>, Rect>,
|
&self.playing as &dyn Focusable<Tui>,
|
||||||
&self.bpm as &dyn Focusable<TuiOutput<'a>, Rect>,
|
&self.bpm as &dyn Focusable<Tui>,
|
||||||
&self.quant as &dyn Focusable<TuiOutput<'a>, Rect>,
|
&self.quant as &dyn Focusable<Tui>,
|
||||||
&self.sync as &dyn Focusable<TuiOutput<'a>, Rect>,
|
&self.sync as &dyn Focusable<Tui>,
|
||||||
&self.clock as &dyn Focusable<TuiOutput<'a>, Rect>,
|
&self.clock as &dyn Focusable<Tui>,
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
fn focusable_mut (&mut self) -> [&mut dyn Focusable<TuiOutput<'a>, Rect>;5] {
|
fn focusable_mut (&mut self) -> [&mut dyn Focusable<Tui>;5] {
|
||||||
[
|
[
|
||||||
&mut self.playing as &mut dyn Focusable<TuiOutput<'a>, Rect>,
|
&mut self.playing as &mut dyn Focusable<Tui>,
|
||||||
&mut self.bpm as &mut dyn Focusable<TuiOutput<'a>, Rect>,
|
&mut self.bpm as &mut dyn Focusable<Tui>,
|
||||||
&mut self.quant as &mut dyn Focusable<TuiOutput<'a>, Rect>,
|
&mut self.quant as &mut dyn Focusable<Tui>,
|
||||||
&mut self.sync as &mut dyn Focusable<TuiOutput<'a>, Rect>,
|
&mut self.sync as &mut dyn Focusable<Tui>,
|
||||||
&mut self.clock as &mut dyn Focusable<TuiOutput<'a>, Rect>,
|
&mut self.clock as &mut dyn Focusable<Tui>,
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<'a> Focusable<TuiOutput<'a>, Rect> for TransportToolbar {
|
impl Focusable<Tui> for TransportToolbar {
|
||||||
fn is_focused (&self) -> bool {
|
fn is_focused (&self) -> bool {
|
||||||
self.focused
|
self.focused
|
||||||
}
|
}
|
||||||
|
|
@ -185,7 +185,7 @@ pub struct TransportPlayPauseButton {
|
||||||
pub value: Option<TransportState>,
|
pub value: Option<TransportState>,
|
||||||
pub focused: bool
|
pub focused: bool
|
||||||
}
|
}
|
||||||
impl<'a> Focusable<TuiOutput<'a>, Rect> for TransportPlayPauseButton {
|
impl Focusable<Tui> for TransportPlayPauseButton {
|
||||||
fn is_focused (&self) -> bool {
|
fn is_focused (&self) -> bool {
|
||||||
self.focused
|
self.focused
|
||||||
}
|
}
|
||||||
|
|
@ -198,7 +198,7 @@ pub struct TransportBPM {
|
||||||
pub value: f64,
|
pub value: f64,
|
||||||
pub focused: bool
|
pub focused: bool
|
||||||
}
|
}
|
||||||
impl<'a> Focusable<TuiOutput<'a>, Rect> for TransportBPM {
|
impl Focusable<Tui> for TransportBPM {
|
||||||
fn is_focused (&self) -> bool {
|
fn is_focused (&self) -> bool {
|
||||||
self.focused
|
self.focused
|
||||||
}
|
}
|
||||||
|
|
@ -211,7 +211,7 @@ pub struct TransportQuantize {
|
||||||
pub value: usize,
|
pub value: usize,
|
||||||
pub focused: bool
|
pub focused: bool
|
||||||
}
|
}
|
||||||
impl<'a> Focusable<TuiOutput<'a>, Rect> for TransportQuantize {
|
impl Focusable<Tui> for TransportQuantize {
|
||||||
fn is_focused (&self) -> bool {
|
fn is_focused (&self) -> bool {
|
||||||
self.focused
|
self.focused
|
||||||
}
|
}
|
||||||
|
|
@ -224,7 +224,7 @@ pub struct TransportSync {
|
||||||
pub value: usize,
|
pub value: usize,
|
||||||
pub focused: bool
|
pub focused: bool
|
||||||
}
|
}
|
||||||
impl<'a> Focusable<TuiOutput<'a>, Rect> for TransportSync {
|
impl Focusable<Tui> for TransportSync {
|
||||||
fn is_focused (&self) -> bool {
|
fn is_focused (&self) -> bool {
|
||||||
self.focused
|
self.focused
|
||||||
}
|
}
|
||||||
|
|
@ -240,7 +240,7 @@ pub struct TransportClock {
|
||||||
pub usecs: usize,
|
pub usecs: usize,
|
||||||
pub focused: bool,
|
pub focused: bool,
|
||||||
}
|
}
|
||||||
impl<'a> Focusable<TuiOutput<'a>, Rect> for TransportClock {
|
impl Focusable<Tui> for TransportClock {
|
||||||
fn is_focused (&self) -> bool {
|
fn is_focused (&self) -> bool {
|
||||||
self.focused
|
self.focused
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
impl Handle<Tui, bool> for TransportToolbar {
|
impl Handle<Tui> for TransportToolbar {
|
||||||
fn handle (&mut self, from: &Tui) -> Perhaps<bool> {
|
fn handle (&mut self, from: &Tui) -> Perhaps<bool> {
|
||||||
Ok(
|
Ok(
|
||||||
from.key(KeyCode::Right).does(||self.focus_next())?
|
from.key(KeyCode::Right).does(||self.focus_next())?
|
||||||
|
|
@ -12,9 +12,14 @@ impl Handle<Tui, bool> for TransportToolbar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handle!(TransportPlayPauseButton |self, _e| Ok(false));
|
impl Handle<Tui> for TransportPlayPauseButton {
|
||||||
|
fn handle (&mut self, from: &Tui) -> Perhaps<bool> {
|
||||||
|
Ok(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
handle!(TransportBPM |self, _e| {
|
impl Handle<Tui> for TransportBPM {
|
||||||
|
fn handle (&mut self, from: &Tui) -> Perhaps<bool> {
|
||||||
//TransportFocus::BPM => {
|
//TransportFocus::BPM => {
|
||||||
//transport.timebase.bpm.fetch_add(1.0, Ordering::Relaxed);
|
//transport.timebase.bpm.fetch_add(1.0, Ordering::Relaxed);
|
||||||
//},
|
//},
|
||||||
|
|
@ -22,9 +27,11 @@ handle!(TransportBPM |self, _e| {
|
||||||
//transport.timebase.bpm.fetch_sub(1.0, Ordering::Relaxed);
|
//transport.timebase.bpm.fetch_sub(1.0, Ordering::Relaxed);
|
||||||
//},
|
//},
|
||||||
Ok(false)
|
Ok(false)
|
||||||
});
|
}
|
||||||
|
}
|
||||||
|
|
||||||
handle!(TransportQuantize |self, _e| {
|
impl Handle<Tui> for TransportQuantize {
|
||||||
|
fn handle (&mut self, from: &Tui) -> Perhaps<bool> {
|
||||||
//TransportFocus::Quant => {
|
//TransportFocus::Quant => {
|
||||||
//transport.quant.value = next_note_length(transport.quant)
|
//transport.quant.value = next_note_length(transport.quant)
|
||||||
//},
|
//},
|
||||||
|
|
@ -32,9 +39,22 @@ handle!(TransportQuantize |self, _e| {
|
||||||
//transport.quant.value = prev_note_length(transport.quant);
|
//transport.quant.value = prev_note_length(transport.quant);
|
||||||
//},
|
//},
|
||||||
Ok(false)
|
Ok(false)
|
||||||
});
|
}
|
||||||
|
}
|
||||||
|
|
||||||
handle!(TransportSync |self, _e| {
|
impl Handle<Tui> for TransportSync {
|
||||||
|
fn handle (&mut self, from: &Tui) -> Perhaps<bool> {
|
||||||
|
//TransportFocus::Sync => {
|
||||||
|
//transport.sync.value = next_note_length(transport.sync)
|
||||||
|
//},
|
||||||
|
//TransportFocus::Sync => {
|
||||||
|
//transport.sync.value = prev_note_length(transport.sync);
|
||||||
|
//},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Handle<Tui> for TransportClock {
|
||||||
|
fn handle (&mut self, from: &Tui) -> Perhaps<bool> {
|
||||||
//TransportFocus::Sync => {
|
//TransportFocus::Sync => {
|
||||||
//transport.sync.value = next_note_length(transport.sync)
|
//transport.sync.value = next_note_length(transport.sync)
|
||||||
//},
|
//},
|
||||||
|
|
@ -42,8 +62,5 @@ handle!(TransportSync |self, _e| {
|
||||||
//transport.sync.value = prev_note_length(transport.sync);
|
//transport.sync.value = prev_note_length(transport.sync);
|
||||||
//},
|
//},
|
||||||
Ok(false)
|
Ok(false)
|
||||||
});
|
}
|
||||||
|
}
|
||||||
handle!(TransportClock |self, _e| {
|
|
||||||
Ok(false)
|
|
||||||
});
|
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@ use crate::*;
|
||||||
|
|
||||||
const CORNERS: Corners = Corners(NOT_DIM_GREEN);
|
const CORNERS: Corners = Corners(NOT_DIM_GREEN);
|
||||||
|
|
||||||
impl<'a> Render<TuiOutput<'a>, Rect> for TransportToolbar {
|
impl Render<Tui> for TransportToolbar {
|
||||||
fn render (&self, target: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
let mut area = target.area;
|
let mut area = to.area();
|
||||||
area.height = 2;
|
area.height = 2;
|
||||||
let area = Split::right()
|
let area = Split::right()
|
||||||
.add_ref(&self.playing)
|
.add_ref(&self.playing)
|
||||||
|
|
@ -12,7 +12,7 @@ impl<'a> Render<TuiOutput<'a>, Rect> for TransportToolbar {
|
||||||
.add_ref(&self.quant)
|
.add_ref(&self.quant)
|
||||||
.add_ref(&self.sync)
|
.add_ref(&self.sync)
|
||||||
.add_ref(&self.clock)
|
.add_ref(&self.clock)
|
||||||
.render(target)?;
|
.render(to)?;
|
||||||
//if self.is_focused() {
|
//if self.is_focused() {
|
||||||
//fill_bg(buf, area, COLOR_BG0);
|
//fill_bg(buf, area, COLOR_BG0);
|
||||||
//CORNERS_DIM.draw(buf, area)?;
|
//CORNERS_DIM.draw(buf, area)?;
|
||||||
|
|
@ -21,9 +21,10 @@ impl<'a> Render<TuiOutput<'a>, Rect> for TransportToolbar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Render<TuiOutput<'a>, Rect> for TransportPlayPauseButton {
|
impl Render<Tui> for TransportPlayPauseButton {
|
||||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
let Rect { x, y, .. } = to.area;
|
let area = to.area();
|
||||||
|
let Rect { x, y, .. } = area;
|
||||||
let Self { value, focused } = &self;
|
let Self { value, focused } = &self;
|
||||||
let style = Some(match value {
|
let style = Some(match value {
|
||||||
Some(TransportState::Stopped) => GRAY_DIM.bold(),
|
Some(TransportState::Stopped) => GRAY_DIM.bold(),
|
||||||
|
|
@ -37,37 +38,40 @@ impl<'a> Render<TuiOutput<'a>, Rect> for TransportPlayPauseButton {
|
||||||
Some(TransportState::Stopped) => "⏹ STOPPED",
|
Some(TransportState::Stopped) => "⏹ STOPPED",
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
let mut area = label.blit(to.buffer, x + 1, y, style)?.unwrap();
|
let mut area = to.blit(&label, x + 1, y, style)?.unwrap();
|
||||||
area.width = area.width + 1;
|
area.width = area.width + 1;
|
||||||
area.height = area.height + 1;
|
area.height = area.height + 1;
|
||||||
if *focused {
|
if *focused {
|
||||||
let area = Rect { x: area.x - 1, width: area.width - 1, ..area };
|
let area = Rect { x: area.x - 1, width: area.width - 1, ..area };
|
||||||
CORNERS.draw(to.buffer, to.area)?;
|
CORNERS.draw(to)?;
|
||||||
fill_bg(to.buffer, to.area, COLOR_BG1);
|
to.fill_bg(area, COLOR_BG1);
|
||||||
}
|
}
|
||||||
Ok(Some(area))
|
Ok(Some(area))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Render<TuiOutput<'a>, Rect> for TransportBPM {
|
impl Render<Tui> for TransportBPM {
|
||||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
let Rect { x, y, .. } = to.area;
|
let area = to.area();
|
||||||
|
let Rect { x, y, .. } = area;
|
||||||
let Self { value, focused } = self;
|
let Self { value, focused } = self;
|
||||||
"BPM".blit(to.buffer, x, y, Some(NOT_DIM))?;
|
to.blit(&"BPM", x, y, Some(NOT_DIM))?;
|
||||||
let width = format!("{}.{:03}", value, (value * 1000.0) % 1000.0)
|
let bpm = format!("{}.{:03}", value, (value * 1000.0) % 1000.0);
|
||||||
.blit(to.buffer, x, y + 1, Some(NOT_DIM_BOLD))?.width;
|
to.blit(&bpm, x, y + 1, Some(NOT_DIM_BOLD))?;
|
||||||
|
let width = bpm.len() as u16;
|
||||||
let area = Rect { x, y, width: (width + 2).max(10), height: 2 };
|
let area = Rect { x, y, width: (width + 2).max(10), height: 2 };
|
||||||
if *focused {
|
if *focused {
|
||||||
let area = Rect { x: area.x - 1, width: area.width - 1, ..area };
|
let area = Rect { x: area.x - 1, width: area.width - 1, ..area };
|
||||||
CORNERS.draw(to.buffer, area)?;
|
CORNERS.draw(to)?;
|
||||||
fill_bg(to.buffer, area, COLOR_BG1);
|
to.fill_bg(area, COLOR_BG1);
|
||||||
}
|
}
|
||||||
Ok(Some(area))
|
Ok(Some(area))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Render<TuiOutput<'a>, Rect> for TransportQuantize {
|
impl Render<Tui> for TransportQuantize {
|
||||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
|
let area = to.area();
|
||||||
let Rect { x, y, .. } = to.area;
|
let Rect { x, y, .. } = to.area;
|
||||||
let Self { value, focused } = self;
|
let Self { value, focused } = self;
|
||||||
"QUANT".blit(to.buffer, x, y, Some(NOT_DIM))?;
|
"QUANT".blit(to.buffer, x, y, Some(NOT_DIM))?;
|
||||||
|
|
@ -75,15 +79,16 @@ impl<'a> Render<TuiOutput<'a>, Rect> for TransportQuantize {
|
||||||
let area = Rect { x, y, width: (width + 2).max(10), height: 2 };
|
let area = Rect { x, y, width: (width + 2).max(10), height: 2 };
|
||||||
if *focused {
|
if *focused {
|
||||||
let area = Rect { x: area.x - 1, width: area.width - 1, ..area };
|
let area = Rect { x: area.x - 1, width: area.width - 1, ..area };
|
||||||
CORNERS.draw(to.buffer, area)?;
|
CORNERS.draw(to)?;
|
||||||
fill_bg(to.buffer, area, COLOR_BG1);
|
to.fill_bg(area, COLOR_BG1);
|
||||||
}
|
}
|
||||||
Ok(Some(area))
|
Ok(Some(area))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Render<TuiOutput<'a>, Rect> for TransportSync {
|
impl Render<Tui> for TransportSync {
|
||||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
|
let area = to.area();
|
||||||
let Rect { x, y, .. } = to.area;
|
let Rect { x, y, .. } = to.area;
|
||||||
let Self { value, focused } = self;
|
let Self { value, focused } = self;
|
||||||
"SYNC".blit(to.buffer, x, y, Some(NOT_DIM))?;
|
"SYNC".blit(to.buffer, x, y, Some(NOT_DIM))?;
|
||||||
|
|
@ -91,31 +96,31 @@ impl<'a> Render<TuiOutput<'a>, Rect> for TransportSync {
|
||||||
let area = Rect { x, y, width: (width + 2).max(10), height: 2 };
|
let area = Rect { x, y, width: (width + 2).max(10), height: 2 };
|
||||||
if *focused {
|
if *focused {
|
||||||
let area = Rect { x: area.x - 1, width: area.width - 1, ..area };
|
let area = Rect { x: area.x - 1, width: area.width - 1, ..area };
|
||||||
CORNERS.draw(to.buffer, area)?;
|
CORNERS.draw(to)?;
|
||||||
fill_bg(to.buffer, area, COLOR_BG1);
|
to.fill_bg(area, COLOR_BG1);
|
||||||
}
|
}
|
||||||
Ok(Some(area))
|
Ok(Some(area))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Render<TuiOutput<'a>, Rect> for TransportClock {
|
impl Render<Tui> for TransportClock {
|
||||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
let Rect { x, y, width, .. } = to.area;
|
let Rect { x, y, width, .. } = to.area();
|
||||||
let Self { frame, pulse, ppq, usecs, focused } = self;
|
let Self { frame, pulse, ppq, usecs, focused } = self;
|
||||||
let (beats, pulses) = if *ppq > 0 { (pulse / ppq, pulse % ppq) } else { (0, 0) };
|
let (beats, pulses) = if *ppq > 0 { (pulse / ppq, pulse % ppq) } else { (0, 0) };
|
||||||
let (bars, beats) = ((beats / 4) + 1, (beats % 4) + 1);
|
let (bars, beats) = ((beats / 4) + 1, (beats % 4) + 1);
|
||||||
let (seconds, msecs) = (usecs / 1000000, usecs / 1000 % 1000);
|
let (seconds, msecs) = (usecs / 1000000, usecs / 1000 % 1000);
|
||||||
let (minutes, seconds) = (seconds / 60, seconds % 60);
|
let (minutes, seconds) = (seconds / 60, seconds % 60);
|
||||||
let timer = format!("{bars}.{beats}.{pulses:02}");
|
let timer = format!("{bars}.{beats}.{pulses:02}");
|
||||||
timer.blit(to.buffer, x + width - timer.len() as u16 - 1, y + 0, Some(NOT_DIM))?;
|
to.blit(&timer, x + width - timer.len() as u16 - 1, y + 0, Some(NOT_DIM))?;
|
||||||
let timer = format!("{minutes}:{seconds:02}:{msecs:03}");
|
let timer = format!("{minutes}:{seconds:02}:{msecs:03}");
|
||||||
timer.blit(to.buffer, x + width - timer.len() as u16 - 1, y + 1, Some(NOT_DIM))?;
|
to.blit(&timer, x + width - timer.len() as u16 - 1, y + 1, Some(NOT_DIM))?;
|
||||||
let mut area = to.area;
|
let mut area = to.area();
|
||||||
area.width = area.width + 1;
|
area.width = area.width + 1;
|
||||||
if *focused {
|
if *focused {
|
||||||
let area = Rect { x: area.x - 1, ..area };
|
let area = Rect { x: area.x - 1, ..area };
|
||||||
CORNERS.draw(to.buffer, area)?;
|
CORNERS.draw(to)?;
|
||||||
fill_bg(to.buffer, area, COLOR_BG1);
|
to.fill_bg(area, COLOR_BG1);
|
||||||
}
|
}
|
||||||
Ok(Some(area))
|
Ok(Some(area))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue