mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
5 compile errors left
This commit is contained in:
parent
7bcd40b425
commit
b3f0f60400
13 changed files with 462 additions and 180 deletions
|
|
@ -1,6 +1,4 @@
|
|||
use crate::*;
|
||||
use std::ops::{Add, Sub};
|
||||
use std::cmp::{Ord, Eq, PartialEq};
|
||||
|
||||
/// Entry point for main loop
|
||||
pub trait App<T: Engine> {
|
||||
|
|
@ -29,18 +27,6 @@ pub trait Engine: Sized {
|
|||
-> &mut Self;
|
||||
}
|
||||
|
||||
pub trait Number: Send + Sync + Copy
|
||||
+ Add<Self, Output=Self>
|
||||
+ Sub<Self, Output=Self>
|
||||
+ Ord + PartialEq + Eq {}
|
||||
|
||||
impl<T> Number for T where
|
||||
T: Send + Sync + Copy
|
||||
+ Add<Self, Output=Self>
|
||||
+ Sub<Self, Output=Self>
|
||||
+ Ord + PartialEq + Eq
|
||||
{}
|
||||
|
||||
submod! {
|
||||
collect
|
||||
component
|
||||
|
|
|
|||
|
|
@ -54,6 +54,13 @@ impl<'a, E: Engine> Collect<'a, E> for Collection<'a, E> {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct Layers<'a, E: Engine>(pub &'a [&'a dyn Render<E>]);
|
||||
|
||||
// this actually works, except for the type inference
|
||||
//pub struct Layers<'a, E: Engine + 'a, I: std::iter::IntoIterator<Item = &'a dyn Render<E>>>(
|
||||
//pub &'a I
|
||||
//);
|
||||
|
||||
pub struct Layered<'a, E: Engine>(pub Collection<'a, E>);
|
||||
|
||||
impl<'a, E: Engine> Layered<'a, E> {
|
||||
|
|
|
|||
|
|
@ -57,13 +57,15 @@ impl<R, E: Engine> Render<E> for RwLock<R> where R: Render<E> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Boxed closures can be rendered.
|
||||
///
|
||||
/// Rendering unboxed closures should also be possible;
|
||||
/// but in practice implementing the trait for an unboxed
|
||||
/// `Fn` closure causes an impl conflict.
|
||||
impl<'a, E: Engine> Render<E> for Box<dyn Fn(&mut E) -> Perhaps<E::Rendered> + Send + Sync + 'a> {
|
||||
fn render (&self, to: &mut E) -> Perhaps<E::Rendered> {
|
||||
(*self)(to)
|
||||
}
|
||||
}
|
||||
// FIXME: components are now 2 thunks (layout and render).
|
||||
// maybe this resolves the conflict describe below?
|
||||
///// Boxed closures can be rendered.
|
||||
/////
|
||||
///// Rendering unboxed closures should also be possible;
|
||||
///// but in practice implementing the trait for an unboxed
|
||||
///// `Fn` closure causes an impl conflict.
|
||||
//impl<'a, E: Engine> Render<E> for Box<dyn Fn(&mut E) -> Perhaps<E::Rendered> + Send + Sync + 'a> {
|
||||
//fn render (&self, to: &mut E) -> Perhaps<E::Rendered> {
|
||||
//(*self)(to)
|
||||
//}
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@ pub(crate) use std::thread::{spawn, JoinHandle};
|
|||
pub(crate) use std::time::Duration;
|
||||
pub(crate) use atomic_float::*;
|
||||
use better_panic::{Settings, Verbosity};
|
||||
use std::ops::{Add, Sub};
|
||||
use std::cmp::{Ord, Eq, PartialEq};
|
||||
use std::fmt::{Debug, Display};
|
||||
|
||||
/// Define and reexport submodules.
|
||||
#[macro_export] macro_rules! submod {
|
||||
|
|
@ -40,3 +43,18 @@ pub type Usually<T> = Result<T, Box<dyn Error>>;
|
|||
|
||||
/// Standard optional result type.
|
||||
pub type Perhaps<T> = Result<Option<T>, Box<dyn Error>>;
|
||||
|
||||
/// Standard numeric type.
|
||||
pub trait Number: Send + Sync + Copy
|
||||
+ Add<Self, Output=Self>
|
||||
+ Sub<Self, Output=Self>
|
||||
+ Ord + PartialEq + Eq
|
||||
+ Debug + Display {}
|
||||
|
||||
impl<T> Number for T where
|
||||
T: Send + Sync + Copy
|
||||
+ Add<Self, Output=Self>
|
||||
+ Sub<Self, Output=Self>
|
||||
+ Ord + PartialEq + Eq
|
||||
+ Debug + Display
|
||||
{}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,13 @@ pub trait Area<N: Number>: Copy {
|
|||
fn lrtb (&self) -> [N;4] {
|
||||
[self.x(), self.x2(), self.y(), self.y2()]
|
||||
}
|
||||
fn expect_min (&self, w: N, h: N) -> Usually<&Self> {
|
||||
if self.w() < w || self.h() < h {
|
||||
Err(format!("min {w}x{h}").into())
|
||||
} else {
|
||||
Ok(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<N: Number> Area<N> for (N, N, N, N) {
|
||||
|
|
|
|||
|
|
@ -201,7 +201,14 @@ pub enum TuiEvent {
|
|||
/// Rendering unit struct to Ratatui returns zero-sized [Area] at render coordinates.
|
||||
impl Render<Tui> for () {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
Ok(Some([to.area.x(), to.area.y(), 0, 0]))
|
||||
self.layout(to.area())
|
||||
}
|
||||
}
|
||||
|
||||
/// Layout of unit struct in Ratatui is zero-sized [Area] at render coordinates.
|
||||
impl Layout<Tui> for () {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
Ok(Some([area.x(), area.y(), 0, 0]))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,8 +86,8 @@ macro_rules! border {
|
|||
($($T:ty {
|
||||
$nw:literal $n:literal $ne:literal $w:literal $e:literal $sw:literal $s:literal $se:literal
|
||||
$($x:tt)*
|
||||
}),+) => {
|
||||
$(impl BorderStyle for $T {
|
||||
}),+) => {$(
|
||||
impl BorderStyle for $T {
|
||||
const NW: &'static str = $nw;
|
||||
const N: &'static str = $n;
|
||||
const NE: &'static str = $ne;
|
||||
|
|
@ -97,8 +97,13 @@ macro_rules! border {
|
|||
const S: &'static str = $s;
|
||||
const SE: &'static str = $se;
|
||||
$($x)*
|
||||
})+
|
||||
}
|
||||
}
|
||||
impl Render<Tui> for $T {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
self.draw(to)
|
||||
}
|
||||
}
|
||||
)+}
|
||||
}
|
||||
|
||||
pub struct Lozenge(pub Style);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,36 @@
|
|||
use crate::*;
|
||||
|
||||
impl Layout<Tui> for &str {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
let [x, y, ..] = area;
|
||||
// TODO: line breaks
|
||||
Ok(Some([x, y, self.len() as u16, 1]))
|
||||
}
|
||||
}
|
||||
|
||||
impl Render<Tui> for &str {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let area = self.layout(to.area())?.unwrap();
|
||||
to.blit(&self, area.x(), area.y(), None)?;
|
||||
Ok(Some(area))
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Styled<T: Layout<Tui>>(pub Option<Style>, pub T);
|
||||
|
||||
impl Layout<Tui> for Styled<&str> {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
Ok(Some([area.x(), area.y(), self.1.len() as u16, 1]))
|
||||
}
|
||||
}
|
||||
|
||||
impl Render<Tui> for Styled<&str> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let area = self.layout(to.area())?.unwrap();
|
||||
Ok(Some([area.x(), area.y(), self.1.len() as u16, 1]))
|
||||
}
|
||||
}
|
||||
|
||||
pub struct FillBg(pub Color);
|
||||
|
||||
impl Render<Tui> for FillBg {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,24 @@
|
|||
use crate::*;
|
||||
|
||||
impl<T: Layout<Tui>> Layout<Tui> for Option<T> {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
match self {
|
||||
Some(layout) => layout.layout(area),
|
||||
None => ().layout(area)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Render<Tui> for Layers<'a, Tui> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let area = to.area();
|
||||
for layer in self.0.iter() {
|
||||
layer.render(to)?;
|
||||
}
|
||||
Ok(Some(area))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Render<Tui> for Layered<'a, Tui> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let area = to.area();
|
||||
|
|
@ -16,6 +35,12 @@ impl<'a> Render<Tui> for Split<'a, Tui> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> Layout<Tui> for Split<'a, Tui> {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
// TODO
|
||||
impl<'a> Split<'a, Tui> {
|
||||
pub fn render_areas (&self, to: &mut Tui) -> Usually<([u16;4], Vec<Option<[u16;4]>>)> {
|
||||
|
|
|
|||
|
|
@ -4,187 +4,235 @@ pub fn draw (state: &Arranger<Tui>, to: &mut Tui) -> Perhaps<[u16;4]> {
|
|||
let area = to.area();
|
||||
let area = [area.x(), area.y(), area.w(), area.h().min((2 + state.tracks.len() * 2) as u16)];
|
||||
let tracks = state.tracks.as_slice();
|
||||
Layered::new()
|
||||
//.add(FillBg(Nord::bg_lo(state.focused, state.entered)))
|
||||
.add(Split::right()
|
||||
Layers(&[
|
||||
&state.focused.then_some(FillBg(COLOR_BG0)),
|
||||
&Split::right()
|
||||
.add(TrackNameColumn(tracks, state.selected))
|
||||
.add(TrackMonitorColumn(tracks))
|
||||
.add(TrackRecordColumn(tracks))
|
||||
.add(TrackOverdubColumn(tracks))
|
||||
.add(TrackEraseColumn(tracks))
|
||||
.add(TrackGainColumn(tracks))
|
||||
.add(TrackScenesColumn(tracks, state.scenes.as_slice(), state.selected)))
|
||||
.render(to)
|
||||
.add(TrackScenesColumn(tracks, state.scenes.as_slice(), state.selected))
|
||||
]).render(to.with_rect(area))
|
||||
}
|
||||
|
||||
struct TrackNameColumn<'a>(&'a [Sequencer], ArrangerFocus);
|
||||
|
||||
impl<'a> Layout<Tui> for TrackNameColumn<'a> {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Render<Tui> for TrackNameColumn<'a> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let Self(tracks, selected) = self;
|
||||
let yellow = Some(Style::default().yellow().bold().not_dim());
|
||||
let white = Some(Style::default().white().bold().not_dim());
|
||||
let area = to.area();
|
||||
let area = [area.x(), area.y(), 3 + 5.max(track_name_max_len(tracks)) as u16, area.h()];
|
||||
let offset = 0; // track scroll offset
|
||||
for y in 0..area.h() {
|
||||
if y == 0 {
|
||||
to.blit(&"Mixer", area.x() + 1, area.y() + y, Some(DIM))?;
|
||||
} else if y % 2 == 0 {
|
||||
let index = (y as usize - 2) / 2 + offset;
|
||||
if let Some(track) = tracks.get(index) {
|
||||
let selected = selected.track() == Some(index);
|
||||
let style = if selected { yellow } else { white };
|
||||
to.blit(&format!(" {index:>02} "), area.x(), area.y() + y, style)?;
|
||||
to.blit(&*track.name.read().unwrap(), area.x() + 4, area.y() + y, style)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(Some(area))
|
||||
todo!();
|
||||
//let Self(tracks, selected) = self;
|
||||
//let yellow = Some(Style::default().yellow().bold().not_dim());
|
||||
//let white = Some(Style::default().white().bold().not_dim());
|
||||
//let area = to.area();
|
||||
//let area = [area.x(), area.y(), 3 + 5.max(track_name_max_len(tracks)) as u16, area.h()];
|
||||
//let offset = 0; // track scroll offset
|
||||
//for y in 0..area.h() {
|
||||
//if y == 0 {
|
||||
//to.blit(&"Mixer", area.x() + 1, area.y() + y, Some(DIM))?;
|
||||
//} else if y % 2 == 0 {
|
||||
//let index = (y as usize - 2) / 2 + offset;
|
||||
//if let Some(track) = tracks.get(index) {
|
||||
//let selected = selected.track() == Some(index);
|
||||
//let style = if selected { yellow } else { white };
|
||||
//to.blit(&format!(" {index:>02} "), area.x(), area.y() + y, style)?;
|
||||
//to.blit(&*track.name.read().unwrap(), area.x() + 4, area.y() + y, style)?;
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
//Ok(Some(area))
|
||||
}
|
||||
}
|
||||
|
||||
struct TrackMonitorColumn<'a>(&'a [Sequencer]);
|
||||
|
||||
impl<'a> Layout<Tui> for TrackMonitorColumn<'a> {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Render<Tui> for TrackMonitorColumn<'a> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let Self(tracks) = self;
|
||||
let mut area = to.area();
|
||||
let on = Some(Style::default().not_dim().green().bold());
|
||||
let off = Some(DIM);
|
||||
area.x += 1;
|
||||
for y in 0..area.h() {
|
||||
if y == 0 {
|
||||
//" MON ".blit(to.buffer, area.x, area.y + y, style2)?;
|
||||
} else if y % 2 == 0 {
|
||||
let index = (y as usize - 2) / 2;
|
||||
if let Some(track) = tracks.get(index) {
|
||||
let style = if track.monitoring { on } else { off };
|
||||
to.blit(&" MON ", area.x(), area.y() + y, style)?;
|
||||
} else {
|
||||
area.height = y;
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
area.width = 4;
|
||||
Ok(Some(area))
|
||||
todo!();
|
||||
//let Self(tracks) = self;
|
||||
//let mut area = to.area();
|
||||
//let on = Some(Style::default().not_dim().green().bold());
|
||||
//let off = Some(DIM);
|
||||
//area.x += 1;
|
||||
//for y in 0..area.h() {
|
||||
//if y == 0 {
|
||||
////" MON ".blit(to.buffer, area.x, area.y + y, style2)?;
|
||||
//} else if y % 2 == 0 {
|
||||
//let index = (y as usize - 2) / 2;
|
||||
//if let Some(track) = tracks.get(index) {
|
||||
//let style = if track.monitoring { on } else { off };
|
||||
//to.blit(&" MON ", area.x(), area.y() + y, style)?;
|
||||
//} else {
|
||||
//area.height = y;
|
||||
//break
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
//area.width = 4;
|
||||
//Ok(Some(area))
|
||||
}
|
||||
}
|
||||
|
||||
struct TrackRecordColumn<'a>(&'a [Sequencer]);
|
||||
|
||||
impl<'a> Layout<Tui> for TrackRecordColumn<'a> {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Render<Tui> for TrackRecordColumn<'a> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let Self(tracks) = self;
|
||||
let mut area = to.area();
|
||||
let on = Some(Style::default().not_dim().red().bold());
|
||||
let off = Some(Style::default().dim());
|
||||
area.x += 1;
|
||||
for y in 0..area.h() {
|
||||
if y == 0 {
|
||||
//" REC ".blit(to.buffer, area.x, area.y + y, style2)?;
|
||||
} else if y % 2 == 0 {
|
||||
let index = (y as usize - 2) / 2;
|
||||
if let Some(track) = tracks.get(index) {
|
||||
let style = if track.recording { on } else { off };
|
||||
to.blit(&" REC ", area.x(), area.y() + y, style)?;
|
||||
} else {
|
||||
area.height = y;
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
area.width = 4;
|
||||
Ok(Some(area))
|
||||
todo!();
|
||||
//let Self(tracks) = self;
|
||||
//let mut area = to.area();
|
||||
//let on = Some(Style::default().not_dim().red().bold());
|
||||
//let off = Some(Style::default().dim());
|
||||
//area.x += 1;
|
||||
//for y in 0..area.h() {
|
||||
//if y == 0 {
|
||||
////" REC ".blit(to.buffer, area.x, area.y + y, style2)?;
|
||||
//} else if y % 2 == 0 {
|
||||
//let index = (y as usize - 2) / 2;
|
||||
//if let Some(track) = tracks.get(index) {
|
||||
//let style = if track.recording { on } else { off };
|
||||
//to.blit(&" REC ", area.x(), area.y() + y, style)?;
|
||||
//} else {
|
||||
//area.height = y;
|
||||
//break
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
//area.width = 4;
|
||||
//Ok(Some(area))
|
||||
}
|
||||
}
|
||||
|
||||
struct TrackOverdubColumn<'a>(&'a [Sequencer]);
|
||||
|
||||
impl<'a> Layout<Tui> for TrackOverdubColumn<'a> {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Render<Tui> for TrackOverdubColumn<'a> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let Self(tracks) = self;
|
||||
let mut area = to.area();
|
||||
let on = Some(Style::default().not_dim().yellow().bold());
|
||||
let off = Some(Style::default().dim());
|
||||
area.x = area.x + 1;
|
||||
for y in 0..area.h() {
|
||||
if y == 0 {
|
||||
//" OVR ".blit(to.buffer, area.x, area.y + y, style2)?;
|
||||
} else if y % 2 == 0 {
|
||||
let index = (y as usize - 2) / 2;
|
||||
if let Some(track) = tracks.get(index) {
|
||||
to.blit(&" OVR ", area.x(), area.y() + y, if track.overdub {
|
||||
on
|
||||
} else {
|
||||
off
|
||||
})?;
|
||||
} else {
|
||||
area.height = y;
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
area.width = 4;
|
||||
Ok(Some(area))
|
||||
todo!();
|
||||
//let Self(tracks) = self;
|
||||
//let mut area = to.area();
|
||||
//let on = Some(Style::default().not_dim().yellow().bold());
|
||||
//let off = Some(Style::default().dim());
|
||||
//area.x = area.x + 1;
|
||||
//for y in 0..area.h() {
|
||||
//if y == 0 {
|
||||
////" OVR ".blit(to.buffer, area.x, area.y + y, style2)?;
|
||||
//} else if y % 2 == 0 {
|
||||
//let index = (y as usize - 2) / 2;
|
||||
//if let Some(track) = tracks.get(index) {
|
||||
//to.blit(&" OVR ", area.x(), area.y() + y, if track.overdub {
|
||||
//on
|
||||
//} else {
|
||||
//off
|
||||
//})?;
|
||||
//} else {
|
||||
//area.height = y;
|
||||
//break
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
//area.width = 4;
|
||||
//Ok(Some(area))
|
||||
}
|
||||
}
|
||||
|
||||
struct TrackEraseColumn<'a>(&'a [Sequencer]);
|
||||
|
||||
impl<'a> Layout<Tui> for TrackEraseColumn<'a> {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Render<Tui> for TrackEraseColumn<'a> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let Self(tracks) = self;
|
||||
let mut area = to.area();
|
||||
let off = Some(Style::default().dim());
|
||||
area.x = area.x + 1;
|
||||
for y in 0..area.h() {
|
||||
if y == 0 {
|
||||
//" DEL ".blit(to.buffer, area.x, area.y + y, style2)?;
|
||||
} else if y % 2 == 0 {
|
||||
let index = (y as usize - 2) / 2;
|
||||
if let Some(_) = tracks.get(index) {
|
||||
to.blit(&" DEL ", area.x(), area.y() + y, off)?;
|
||||
} else {
|
||||
area.height = y;
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
area.width = 4;
|
||||
Ok(Some(area))
|
||||
todo!();
|
||||
//let Self(tracks) = self;
|
||||
//let mut area = to.area();
|
||||
//let off = Some(Style::default().dim());
|
||||
//area.x = area.x + 1;
|
||||
//for y in 0..area.h() {
|
||||
//if y == 0 {
|
||||
////" DEL ".blit(to.buffer, area.x, area.y + y, style2)?;
|
||||
//} else if y % 2 == 0 {
|
||||
//let index = (y as usize - 2) / 2;
|
||||
//if let Some(_) = tracks.get(index) {
|
||||
//to.blit(&" DEL ", area.x(), area.y() + y, off)?;
|
||||
//} else {
|
||||
//area.height = y;
|
||||
//break
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
//area.width = 4;
|
||||
//Ok(Some(area))
|
||||
}
|
||||
}
|
||||
|
||||
struct TrackGainColumn<'a>(&'a [Sequencer]);
|
||||
|
||||
impl<'a> Layout<Tui> for TrackGainColumn<'a> {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Render<Tui> for TrackGainColumn<'a> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let Self(tracks) = self;
|
||||
let mut area = to.area();
|
||||
let off = Some(Style::default().dim());
|
||||
area.x = area.x() + 1;
|
||||
for y in 0..area.h() {
|
||||
if y == 0 {
|
||||
//" GAIN ".blit(to.buffer, area.x, area.y + y, style2)?;
|
||||
} else if y % 2 == 0 {
|
||||
let index = (y as usize - 2) / 2;
|
||||
if let Some(_) = tracks.get(index) {
|
||||
to.blit(&" +0.0 ", area.x(), area.y() + y, off)?;
|
||||
} else {
|
||||
area.height = y;
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
area.width = 7;
|
||||
Ok(Some(area))
|
||||
todo!();
|
||||
//let Self(tracks) = self;
|
||||
//let mut area = to.area();
|
||||
//let off = Some(Style::default().dim());
|
||||
//area.x = area.x() + 1;
|
||||
//for y in 0..area.h() {
|
||||
//if y == 0 {
|
||||
////" GAIN ".blit(to.buffer, area.x, area.y + y, style2)?;
|
||||
//} else if y % 2 == 0 {
|
||||
//let index = (y as usize - 2) / 2;
|
||||
//if let Some(_) = tracks.get(index) {
|
||||
//to.blit(&" +0.0 ", area.x(), area.y() + y, off)?;
|
||||
//} else {
|
||||
//area.height = y;
|
||||
//break
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
//area.width = 7;
|
||||
//Ok(Some(area))
|
||||
}
|
||||
}
|
||||
|
||||
struct TrackScenesColumn<'a>(&'a [Sequencer], &'a [Scene], ArrangerFocus);
|
||||
|
||||
impl<'a> Layout<Tui> for TrackScenesColumn<'a> {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Render<Tui> for TrackScenesColumn<'a> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let Self(tracks, scenes, selected) = self;
|
||||
|
|
|
|||
|
|
@ -51,6 +51,12 @@ pub fn draw <'a, 'b> (
|
|||
|
||||
struct ColumnSeparators<'a>(u16, &'a [(usize, usize)]);
|
||||
|
||||
impl<'a> Layout<Tui> for ColumnSeparators<'a> {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Render<Tui> for ColumnSeparators<'a> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let area = to.area();
|
||||
|
|
@ -68,6 +74,12 @@ impl<'a> Render<Tui> for ColumnSeparators<'a> {
|
|||
|
||||
struct RowSeparators<'a>(&'a [(usize, usize)]);
|
||||
|
||||
impl<'a> Layout<Tui> for RowSeparators<'a> {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Render<Tui> for RowSeparators<'a> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let area = to.area();
|
||||
|
|
@ -91,6 +103,12 @@ struct CursorFocus<'a>(
|
|||
ArrangerFocus, u16, &'a [(usize, usize)], &'a [(usize, usize)]
|
||||
);
|
||||
|
||||
impl<'a> Layout<Tui> for CursorFocus<'a> {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Render<Tui> for CursorFocus<'a> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let area = to.area();
|
||||
|
|
@ -157,6 +175,12 @@ impl<'a> Render<Tui> for CursorFocus<'a> {
|
|||
|
||||
struct TracksHeader<'a>(u16, &'a[(usize, usize)], &'a [Sequencer]);
|
||||
|
||||
impl<'a> Layout<Tui> for TracksHeader<'a> {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Render<Tui> for TracksHeader<'a> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let area = to.area();
|
||||
|
|
@ -177,6 +201,12 @@ impl<'a> Render<Tui> for TracksHeader<'a> {
|
|||
|
||||
struct SceneRows<'a>(u16, &'a[(usize, usize)], &'a[(usize, usize)], &'a[Sequencer], &'a[Scene]);
|
||||
|
||||
impl<'a> Layout<Tui> for SceneRows<'a> {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Render<Tui> for SceneRows<'a> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let area = to.area();
|
||||
|
|
@ -206,6 +236,12 @@ impl<'a> Render<Tui> for SceneRows<'a> {
|
|||
|
||||
struct SceneRow<'a>(&'a[Sequencer], &'a Scene, &'a[(usize, usize)], u16);
|
||||
|
||||
impl<'a> Layout<Tui> for SceneRow<'a> {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Render<Tui> for SceneRow<'a> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let area = to.area();
|
||||
|
|
@ -232,6 +268,12 @@ impl<'a> Render<Tui> for SceneRow<'a> {
|
|||
|
||||
struct SceneClip<'a>(&'a Sequencer, usize);
|
||||
|
||||
impl<'a> Layout<Tui> for SceneClip<'a> {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Render<Tui> for SceneClip<'a> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let area = to.area();
|
||||
|
|
|
|||
|
|
@ -48,6 +48,12 @@ const STYLE_VALUE: Option<Style> = Some(Style {
|
|||
|
||||
struct SequenceName<'a>(&'a Sequencer);
|
||||
|
||||
impl<'a> Layout<Tui> for SequenceName<'a> {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Render<Tui> for SequenceName<'a> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let [x, y, ..] = to.area();
|
||||
|
|
@ -61,6 +67,12 @@ impl<'a> Render<Tui> for SequenceName<'a> {
|
|||
|
||||
struct SequenceRange;
|
||||
|
||||
impl Layout<Tui> for SequenceRange {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Render<Tui> for SequenceRange {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let [x, y, ..] = to.area();
|
||||
|
|
@ -76,6 +88,12 @@ impl<'a> Render<Tui> for SequenceRange {
|
|||
|
||||
struct SequenceLoopRange;
|
||||
|
||||
impl Layout<Tui> for SequenceLoopRange {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Render<Tui> for SequenceLoopRange {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let [x, y, ..] = to.area();
|
||||
|
|
@ -92,6 +110,12 @@ impl<'a> Render<Tui> for SequenceLoopRange {
|
|||
|
||||
struct SequenceNoteRange;
|
||||
|
||||
impl Layout<Tui> for SequenceNoteRange {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Render<Tui> for SequenceNoteRange {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let [x, y, ..] = to.area();
|
||||
|
|
@ -110,6 +134,12 @@ impl<'a> Render<Tui> for SequenceNoteRange {
|
|||
|
||||
struct SequenceKeys<'a>(&'a Sequencer);
|
||||
|
||||
impl<'a> Layout<Tui> for SequenceKeys<'a> {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Render<Tui> for SequenceKeys<'a> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let area = to.area();
|
||||
|
|
@ -129,6 +159,12 @@ impl<'a> Render<Tui> for SequenceKeys<'a> {
|
|||
|
||||
struct SequenceNotes<'a>(&'a Sequencer);
|
||||
|
||||
impl<'a> Layout<Tui> for SequenceNotes<'a> {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Render<Tui> for SequenceNotes<'a> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let area = to.area();
|
||||
|
|
@ -158,6 +194,12 @@ impl<'a> Render<Tui> for SequenceNotes<'a> {
|
|||
|
||||
struct SequenceCursor<'a>(&'a Sequencer);
|
||||
|
||||
impl<'a> Layout<Tui> for SequenceCursor<'a> {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Render<Tui> for SequenceCursor<'a> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let area = to.area();
|
||||
|
|
@ -174,6 +216,12 @@ impl<'a> Render<Tui> for SequenceCursor<'a> {
|
|||
|
||||
struct SequenceZoom<'a>(&'a Sequencer);
|
||||
|
||||
impl<'a> Layout<Tui> for SequenceZoom<'a> {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Render<Tui> for SequenceZoom<'a> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let area = to.area();
|
||||
|
|
@ -186,6 +234,12 @@ impl<'a> Render<Tui> for SequenceZoom<'a> {
|
|||
|
||||
struct SequenceTimer<'a>(&'a Sequencer, Arc<RwLock<Phrase>>);
|
||||
|
||||
impl<'a> Layout<Tui> for SequenceTimer<'a> {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Render<Tui> for SequenceTimer<'a> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let area = to.area();
|
||||
|
|
|
|||
|
|
@ -21,31 +21,60 @@ impl Render<Tui> for TransportToolbar {
|
|||
}
|
||||
}
|
||||
|
||||
impl Layout<Tui> for TransportPlayPauseButton {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
area.expect_min(10, 1)?;
|
||||
Ok(Some([area.x(), area.y(), 10, 1]))
|
||||
}
|
||||
}
|
||||
|
||||
impl Render<Tui> for TransportPlayPauseButton {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let area = to.area();
|
||||
let [x, y, ..] = area;
|
||||
let Self { value, focused } = &self;
|
||||
let style = Some(match value {
|
||||
Some(TransportState::Stopped) => GRAY_DIM.bold(),
|
||||
Some(TransportState::Starting) => GRAY_NOT_DIM_BOLD,
|
||||
Some(TransportState::Rolling) => WHITE_NOT_DIM_BOLD,
|
||||
_ => unreachable!(),
|
||||
});
|
||||
let label = match value {
|
||||
Some(TransportState::Rolling) => "▶ PLAYING",
|
||||
Some(TransportState::Starting) => "READY ...",
|
||||
Some(TransportState::Stopped) => "⏹ STOPPED",
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let area = to.blit(&label, x + 1, y, style)?.unwrap();
|
||||
let area = [area.x(), area.y(), area.w() + 1, area.h() + 1];
|
||||
if *focused {
|
||||
let area = [area.x() - 1, area.y(), area.w() - 1, area.h() ];
|
||||
CORNERS.draw(to)?;
|
||||
to.fill_bg(area, COLOR_BG1);
|
||||
}
|
||||
Ok(Some(area))
|
||||
Layers(&[
|
||||
&focused.then_some(CORNERS),
|
||||
&Inset::W(1, Styled(match value {
|
||||
Some(TransportState::Stopped) => Some(GRAY_DIM.bold()),
|
||||
Some(TransportState::Starting) => Some(GRAY_NOT_DIM_BOLD),
|
||||
Some(TransportState::Rolling) => Some(WHITE_NOT_DIM_BOLD),
|
||||
_ => unreachable!(),
|
||||
}, match value {
|
||||
Some(TransportState::Rolling) => "▶ PLAYING",
|
||||
Some(TransportState::Starting) => "READY ...",
|
||||
Some(TransportState::Stopped) => "⏹ STOPPED",
|
||||
_ => unreachable!(),
|
||||
}))
|
||||
]).render(to)
|
||||
//let area = to.area();
|
||||
//let [x, y, ..] = area;
|
||||
//let Self { value, focused } = &self;
|
||||
//let style = Some(match value {
|
||||
//Some(TransportState::Stopped) => GRAY_DIM.bold(),
|
||||
//Some(TransportState::Starting) => GRAY_NOT_DIM_BOLD,
|
||||
//Some(TransportState::Rolling) => WHITE_NOT_DIM_BOLD,
|
||||
//_ => unreachable!(),
|
||||
//});
|
||||
//let label = match value {
|
||||
//Some(TransportState::Rolling) => "▶ PLAYING",
|
||||
//Some(TransportState::Starting) => "READY ...",
|
||||
//Some(TransportState::Stopped) => "⏹ STOPPED",
|
||||
//_ => unreachable!(),
|
||||
//};
|
||||
//let area = to.blit(&label, x + 1, y, style)?.unwrap();
|
||||
//let area = [area.x(), area.y(), area.w() + 1, area.h() + 1];
|
||||
//if *focused {
|
||||
//let area = [area.x() - 1, area.y(), area.w() - 1, area.h() ];
|
||||
//CORNERS.draw(to)?;
|
||||
//to.fill_bg(area, COLOR_BG1);
|
||||
//}
|
||||
//Ok(Some(area))
|
||||
}
|
||||
}
|
||||
|
||||
impl Layout<Tui> for TransportBPM {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
area.expect_min(10, 1)?;
|
||||
Ok(Some([area.x(), area.y(), 10, 1]))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -68,6 +97,13 @@ impl Render<Tui> for TransportBPM {
|
|||
}
|
||||
}
|
||||
|
||||
impl Layout<Tui> for TransportQuantize {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
area.expect_min(10, 1)?;
|
||||
Ok(Some([area.x(), area.y(), 10, 1]))
|
||||
}
|
||||
}
|
||||
|
||||
impl Render<Tui> for TransportQuantize {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let [x, y, ..] = to.area();
|
||||
|
|
@ -86,6 +122,13 @@ impl Render<Tui> for TransportQuantize {
|
|||
}
|
||||
}
|
||||
|
||||
impl Layout<Tui> for TransportSync {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
area.expect_min(10, 1)?;
|
||||
Ok(Some([area.x(), area.y(), 10, 1]))
|
||||
}
|
||||
}
|
||||
|
||||
impl Render<Tui> for TransportSync {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let [x, y, ..] = to.area();
|
||||
|
|
@ -104,6 +147,13 @@ impl Render<Tui> for TransportSync {
|
|||
}
|
||||
}
|
||||
|
||||
impl Layout<Tui> for TransportClock {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
area.expect_min(10, 1)?;
|
||||
Ok(Some([area.x(), area.y(), 20, 1]))
|
||||
}
|
||||
}
|
||||
|
||||
impl Render<Tui> for TransportClock {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let [x, y, width, _] = to.area();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue