mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 20:56:43 +01:00
wip: replacing Rect with [u16;4] in mixer and sequencer
This commit is contained in:
parent
fa739a49b2
commit
06f8bd1116
14 changed files with 106 additions and 106 deletions
|
|
@ -4,7 +4,7 @@ pub struct FillBg(pub Color);
|
||||||
|
|
||||||
impl Render<Tui> for FillBg {
|
impl Render<Tui> for FillBg {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
to.fill_bg(to.area(), self.0);
|
to.fill_bg(to.area, self.0);
|
||||||
Ok(Some(to.area))
|
Ok(Some(to.area))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ impl<E: Engine> Process for Mixer<E> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Render<Tui> for Mixer<Tui> {
|
impl Render<Tui> for Mixer<Tui> {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let mut tracks = Split::right();
|
let mut tracks = Split::right();
|
||||||
for channel in self.tracks.iter() {
|
for channel in self.tracks.iter() {
|
||||||
tracks = tracks.add_ref(channel)
|
tracks = tracks.add_ref(channel)
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@ impl Handle<Tui> for Plugin {
|
||||||
}
|
}
|
||||||
process!(Plugin = Plugin::process);
|
process!(Plugin = Plugin::process);
|
||||||
impl Render<Tui> for Plugin {
|
impl Render<Tui> for Plugin {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let area = to.area();
|
let area = to.area();
|
||||||
let Rect { x, y, height, .. } = area;
|
let [x, y, _, height] = area;
|
||||||
let mut width = 20u16;
|
let mut width = 20u16;
|
||||||
match &self.plugin {
|
match &self.plugin {
|
||||||
Some(PluginKind::LV2(LV2Plugin { port_list, instance, .. })) => {
|
Some(PluginKind::LV2(LV2Plugin { port_list, instance, .. })) => {
|
||||||
|
|
@ -48,8 +48,8 @@ impl Render<Tui> for Plugin {
|
||||||
},
|
},
|
||||||
_ => {}
|
_ => {}
|
||||||
};
|
};
|
||||||
draw_header(self, to, area.x, area.y, width)?;
|
draw_header(self, to, x, y, width)?;
|
||||||
Ok(Some(Rect { width, ..to.area() }))
|
Ok(Some([x, y, width, height]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ pub struct AddSampleModal {
|
||||||
exit!(AddSampleModal);
|
exit!(AddSampleModal);
|
||||||
|
|
||||||
impl Render<Tui> for AddSampleModal {
|
impl Render<Tui> for AddSampleModal {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let area = to.area();
|
let area = to.area();
|
||||||
to.make_dim();
|
to.make_dim();
|
||||||
let area = center_box(
|
let area = center_box(
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
impl Render<Tui> for Sampler {
|
impl Render<Tui> for Sampler {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
tui_render_sampler(self, to)
|
tui_render_sampler(self, to)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tui_render_sampler (sampler: &Sampler, to: &mut Tui) -> Perhaps<Rect> {
|
pub fn tui_render_sampler (sampler: &Sampler, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let Rect { x, y, height, .. } = to.area();
|
let [x, y, _, height] = to.area();
|
||||||
let style = Style::default().gray();
|
let style = Style::default().gray();
|
||||||
let title = format!(" {} ({})", sampler.name, sampler.voices.read().unwrap().len());
|
let title = format!(" {} ({})", sampler.name, sampler.voices.read().unwrap().len());
|
||||||
to.blit(&title, x+1, y, Some(style.white().bold().not_dim()))?;
|
to.blit(&title, x+1, y, Some(style.white().bold().not_dim()))?;
|
||||||
|
|
@ -29,7 +29,7 @@ pub fn tui_render_sampler (sampler: &Sampler, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
j = j + 1;
|
j = j + 1;
|
||||||
}
|
}
|
||||||
let height = ((2 + y1) as u16).min(height);
|
let height = ((2 + y1) as u16).min(height);
|
||||||
Ok(Some(Rect { x, y, width: (width as u16).min(to.area().width), height }))
|
Ok(Some([x, y, (width as u16).min(to.area().w()), height]))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_sample (
|
fn draw_sample (
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use crate::*;
|
||||||
use tek_core::Direction;
|
use tek_core::Direction;
|
||||||
|
|
||||||
impl Render<Tui> for Track<Tui> {
|
impl Render<Tui> for Track<Tui> {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
TrackView {
|
TrackView {
|
||||||
chain: Some(&self),
|
chain: Some(&self),
|
||||||
direction: tek_core::Direction::Right,
|
direction: tek_core::Direction::Right,
|
||||||
|
|
@ -31,7 +31,7 @@ pub struct TrackView<'a, E: Engine> {
|
||||||
pub entered: bool,
|
pub entered: bool,
|
||||||
}
|
}
|
||||||
impl<'a> Render<Tui> for TrackView<'a, Tui> {
|
impl<'a> Render<Tui> for TrackView<'a, Tui> {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let mut area = to.area();
|
let mut area = to.area();
|
||||||
if let Some(chain) = self.chain {
|
if let Some(chain) = self.chain {
|
||||||
match self.direction {
|
match self.direction {
|
||||||
|
|
@ -50,7 +50,7 @@ impl<'a> Render<Tui> for TrackView<'a, Tui> {
|
||||||
}
|
}
|
||||||
Ok(Some(area))
|
Ok(Some(area))
|
||||||
} else {
|
} else {
|
||||||
let Rect { x, y, width, height } = area;
|
let [x, y, width, height] = area;
|
||||||
let label = "No chain selected";
|
let label = "No chain selected";
|
||||||
let x = x + (width - label.len() as u16) / 2;
|
let x = x + (width - label.len() as u16) / 2;
|
||||||
let y = y + height / 2;
|
let y = y + height / 2;
|
||||||
|
|
|
||||||
|
|
@ -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 (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
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,19 +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.alter_area(|x, y, w, h|(
|
})(&mut to.alter_area(|[x, y, w, h]|[
|
||||||
x + 1,
|
x + 1,
|
||||||
y + 1,
|
y + 1,
|
||||||
w.saturating_sub(2),
|
w.saturating_sub(2),
|
||||||
h.saturating_sub(2),
|
h.saturating_sub(2),
|
||||||
)))?.unwrap();
|
]))?.unwrap();
|
||||||
Lozenge(Style::default().fg(Nord::BG2))
|
Lozenge(Style::default().fg(Nord::BG2))
|
||||||
.draw(&mut to.alter_area(|x, y, w, h|(
|
.draw(&mut to.alter_area(|[x, y, w, h]|[
|
||||||
x.saturating_sub(1),
|
x.saturating_sub(1),
|
||||||
y.saturating_sub(1),
|
y.saturating_sub(1),
|
||||||
w + 2,
|
w + 2,
|
||||||
h + 2,
|
h + 2,
|
||||||
)))
|
]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Focusable<Tui> for Arranger<Tui> {
|
impl Focusable<Tui> for Arranger<Tui> {
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ impl<E: Engine> ArrangerStandalone<E> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render<Tui> for ArrangerStandalone<Tui> {
|
impl Render<Tui> for ArrangerStandalone<Tui> {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let area = to.area();
|
let area = to.area();
|
||||||
let sequencer = self.arranger.sequencer();
|
let sequencer = self.arranger.sequencer();
|
||||||
let result = Split::down()
|
let result = Split::down()
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ impl ArrangerRenameModal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Render<Tui> for ArrangerRenameModal {
|
impl Render<Tui> for ArrangerRenameModal {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let area = to.area();
|
let area = to.area();
|
||||||
let y = area.y + area.height / 2;
|
let y = area.y + area.height / 2;
|
||||||
let bg_area = Rect {
|
let bg_area = Rect {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
pub fn draw (state: &Arranger<Tui>, to: &mut Tui) -> Perhaps<Rect> {
|
pub fn draw (state: &Arranger<Tui>, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let mut area = to.area();
|
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();
|
||||||
|
|
@ -20,7 +20,7 @@ pub fn draw (state: &Arranger<Tui>, to: &mut Tui) -> Perhaps<Rect> {
|
||||||
struct TrackNameColumn<'a>(&'a [Sequencer], ArrangerFocus);
|
struct TrackNameColumn<'a>(&'a [Sequencer], ArrangerFocus);
|
||||||
|
|
||||||
impl<'a> Render<Tui> for TrackNameColumn<'a> {
|
impl<'a> Render<Tui> for TrackNameColumn<'a> {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
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());
|
||||||
|
|
@ -47,7 +47,7 @@ impl<'a> Render<Tui> for TrackNameColumn<'a> {
|
||||||
struct TrackMonitorColumn<'a>(&'a [Sequencer]);
|
struct TrackMonitorColumn<'a>(&'a [Sequencer]);
|
||||||
|
|
||||||
impl<'a> Render<Tui> for TrackMonitorColumn<'a> {
|
impl<'a> Render<Tui> for TrackMonitorColumn<'a> {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
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());
|
||||||
|
|
@ -75,7 +75,7 @@ impl<'a> Render<Tui> for TrackMonitorColumn<'a> {
|
||||||
struct TrackRecordColumn<'a>(&'a [Sequencer]);
|
struct TrackRecordColumn<'a>(&'a [Sequencer]);
|
||||||
|
|
||||||
impl<'a> Render<Tui> for TrackRecordColumn<'a> {
|
impl<'a> Render<Tui> for TrackRecordColumn<'a> {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
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());
|
||||||
|
|
@ -103,7 +103,7 @@ impl<'a> Render<Tui> for TrackRecordColumn<'a> {
|
||||||
struct TrackOverdubColumn<'a>(&'a [Sequencer]);
|
struct TrackOverdubColumn<'a>(&'a [Sequencer]);
|
||||||
|
|
||||||
impl<'a> Render<Tui> for TrackOverdubColumn<'a> {
|
impl<'a> Render<Tui> for TrackOverdubColumn<'a> {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
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());
|
||||||
|
|
@ -134,7 +134,7 @@ impl<'a> Render<Tui> for TrackOverdubColumn<'a> {
|
||||||
struct TrackEraseColumn<'a>(&'a [Sequencer]);
|
struct TrackEraseColumn<'a>(&'a [Sequencer]);
|
||||||
|
|
||||||
impl<'a> Render<Tui> for TrackEraseColumn<'a> {
|
impl<'a> Render<Tui> for TrackEraseColumn<'a> {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
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());
|
||||||
|
|
@ -160,7 +160,7 @@ impl<'a> Render<Tui> for TrackEraseColumn<'a> {
|
||||||
struct TrackGainColumn<'a>(&'a [Sequencer]);
|
struct TrackGainColumn<'a>(&'a [Sequencer]);
|
||||||
|
|
||||||
impl<'a> Render<Tui> for TrackGainColumn<'a> {
|
impl<'a> Render<Tui> for TrackGainColumn<'a> {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
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());
|
||||||
|
|
@ -186,11 +186,11 @@ impl<'a> Render<Tui> for TrackGainColumn<'a> {
|
||||||
struct TrackScenesColumn<'a>(&'a [Sequencer], &'a [Scene], ArrangerFocus);
|
struct TrackScenesColumn<'a>(&'a [Sequencer], &'a [Scene], ArrangerFocus);
|
||||||
|
|
||||||
impl<'a> Render<Tui> for TrackScenesColumn<'a> {
|
impl<'a> Render<Tui> for TrackScenesColumn<'a> {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
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 [x, y, _, height] = area;
|
||||||
for (scene_index, scene) in scenes.iter().enumerate() {
|
for (scene_index, scene) in scenes.iter().enumerate() {
|
||||||
let active_scene = selected.scene() == Some(scene_index);
|
let active_scene = selected.scene() == Some(scene_index);
|
||||||
let sep = Some(if active_scene {
|
let sep = Some(if active_scene {
|
||||||
|
|
@ -222,6 +222,6 @@ impl<'a> Render<Tui> for TrackScenesColumn<'a> {
|
||||||
}
|
}
|
||||||
x2 = x2 + x3 + 1;
|
x2 = x2 + x3 + 1;
|
||||||
}
|
}
|
||||||
Ok(Some(Rect { x, y, height, width: x2 }))
|
Ok(Some([x, y, x2, height]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use crate::*;
|
||||||
/// Draw arranger with 1 row per scene.
|
/// Draw arranger with 1 row per scene.
|
||||||
pub fn draw_compact_1 <'a> (
|
pub fn draw_compact_1 <'a> (
|
||||||
state: &Arranger<Tui>, to: &mut Tui
|
state: &Arranger<Tui>, to: &mut Tui
|
||||||
) -> Perhaps<Rect> {
|
) -> Perhaps<[u16;4]> {
|
||||||
let track_cols = track_clip_name_lengths(state.tracks.as_slice());
|
let track_cols = track_clip_name_lengths(state.tracks.as_slice());
|
||||||
let scene_rows = (0..=state.scenes.len()).map(|i|(96, 96*i)).collect::<Vec<_>>();
|
let scene_rows = (0..=state.scenes.len()).map(|i|(96, 96*i)).collect::<Vec<_>>();
|
||||||
draw(state, to, track_cols.as_slice(), scene_rows.as_slice())
|
draw(state, to, track_cols.as_slice(), scene_rows.as_slice())
|
||||||
|
|
@ -12,7 +12,7 @@ pub fn draw_compact_1 <'a> (
|
||||||
/// Draw arranger with 2 rows per scene.
|
/// Draw arranger with 2 rows per scene.
|
||||||
pub fn draw_compact_2 <'a> (
|
pub fn draw_compact_2 <'a> (
|
||||||
state: &Arranger<Tui>, to: &mut Tui
|
state: &Arranger<Tui>, to: &mut Tui
|
||||||
) -> Perhaps<Rect> {
|
) -> Perhaps<[u16;4]> {
|
||||||
let track_cols = track_clip_name_lengths(state.tracks.as_slice());
|
let track_cols = track_clip_name_lengths(state.tracks.as_slice());
|
||||||
let scene_rows = (0..=state.scenes.len()).map(|i|(192, 192*i)).collect::<Vec<_>>();
|
let scene_rows = (0..=state.scenes.len()).map(|i|(192, 192*i)).collect::<Vec<_>>();
|
||||||
draw(state, to, track_cols.as_slice(), scene_rows.as_slice())
|
draw(state, to, track_cols.as_slice(), scene_rows.as_slice())
|
||||||
|
|
@ -21,7 +21,7 @@ pub fn draw_compact_2 <'a> (
|
||||||
/// Draw arranger with number of rows per scene proportional to duration of scene.
|
/// Draw arranger with number of rows per scene proportional to duration of scene.
|
||||||
pub fn draw_expanded <'a> (
|
pub fn draw_expanded <'a> (
|
||||||
state: &Arranger<Tui>, to: &mut Tui
|
state: &Arranger<Tui>, to: &mut Tui
|
||||||
) -> Perhaps<Rect> {
|
) -> Perhaps<[u16;4]> {
|
||||||
let track_cols = track_clip_name_lengths(state.tracks.as_slice());
|
let track_cols = track_clip_name_lengths(state.tracks.as_slice());
|
||||||
let scene_rows = scene_ppqs(state.tracks.as_slice(), state.scenes.as_slice());
|
let scene_rows = scene_ppqs(state.tracks.as_slice(), state.scenes.as_slice());
|
||||||
draw(state, to, track_cols.as_slice(), scene_rows.as_slice())
|
draw(state, to, track_cols.as_slice(), scene_rows.as_slice())
|
||||||
|
|
@ -32,7 +32,7 @@ pub fn draw <'a, 'b> (
|
||||||
to: &mut Tui,
|
to: &mut Tui,
|
||||||
cols: &'b [(usize, usize)],
|
cols: &'b [(usize, usize)],
|
||||||
rows: &'b [(usize, usize)],
|
rows: &'b [(usize, usize)],
|
||||||
) -> Perhaps<Rect> {
|
) -> Perhaps<[u16;4]> {
|
||||||
let mut area = to.area();
|
let mut area = to.area();
|
||||||
area.height = 2 + (rows[rows.len() - 1].1 / 96) as u16;
|
area.height = 2 + (rows[rows.len() - 1].1 / 96) as u16;
|
||||||
let offset = 3 + scene_name_max_len(state.scenes.as_ref()) as u16;
|
let offset = 3 + scene_name_max_len(state.scenes.as_ref()) as u16;
|
||||||
|
|
@ -52,7 +52,7 @@ pub fn draw <'a, 'b> (
|
||||||
struct ColumnSeparators<'a>(u16, &'a [(usize, usize)]);
|
struct ColumnSeparators<'a>(u16, &'a [(usize, usize)]);
|
||||||
|
|
||||||
impl<'a> Render<Tui> for ColumnSeparators<'a> {
|
impl<'a> Render<Tui> for ColumnSeparators<'a> {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let area = to.area();
|
let area = to.area();
|
||||||
let Self(offset, cols) = self;
|
let Self(offset, cols) = self;
|
||||||
let style = Some(Style::default().fg(Nord::SEPARATOR));
|
let style = Some(Style::default().fg(Nord::SEPARATOR));
|
||||||
|
|
@ -69,7 +69,7 @@ impl<'a> Render<Tui> for ColumnSeparators<'a> {
|
||||||
struct RowSeparators<'a>(&'a [(usize, usize)]);
|
struct RowSeparators<'a>(&'a [(usize, usize)]);
|
||||||
|
|
||||||
impl<'a> Render<Tui> for RowSeparators<'a> {
|
impl<'a> Render<Tui> for RowSeparators<'a> {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let area = to.area();
|
let area = to.area();
|
||||||
let Self(rows) = self;
|
let Self(rows) = self;
|
||||||
for (_, y) in rows.iter() {
|
for (_, y) in rows.iter() {
|
||||||
|
|
@ -92,30 +92,30 @@ struct CursorFocus<'a>(
|
||||||
);
|
);
|
||||||
|
|
||||||
impl<'a> Render<Tui> for CursorFocus<'a> {
|
impl<'a> Render<Tui> for CursorFocus<'a> {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let mut area = to.area();
|
let mut area = to.area();
|
||||||
let Self(selected, offset, cols, rows) = *self;
|
let Self(selected, offset, cols, rows) = *self;
|
||||||
let get_track_area = |t: usize| Rect {
|
let get_track_area = |t: usize| [
|
||||||
x: offset + area.x + cols[t].1 as u16 - 1,
|
offset + area.x() + cols[t].1 as u16 - 1,
|
||||||
y: area.y,
|
area.y(),
|
||||||
width: cols[t].0 as u16,
|
cols[t].0 as u16,
|
||||||
height: area.height
|
area.h()
|
||||||
};
|
];
|
||||||
let get_scene_area = |s: usize| Rect {
|
let get_scene_area = |s: usize| [
|
||||||
x: area.x,
|
area.x(),
|
||||||
y: 2 + area.y + (rows[s].1 / 96) as u16,
|
2 + area.y() + (rows[s].1 / 96) as u16,
|
||||||
width: area.width,
|
area.w(),
|
||||||
height: (rows[s].0 / 96) as u16
|
(rows[s].0 / 96) as u16
|
||||||
};
|
];
|
||||||
let get_clip_area = |t: usize, s: usize| Rect {
|
let get_clip_area = |t: usize, s: usize| [
|
||||||
x: offset + area.x + cols[t].1 as u16 - 1,
|
offset + area.x() + cols[t].1 as u16 - 1,
|
||||||
y: 2 + area.y + (rows[s].1 / 96) as u16,
|
2 + area.y() + (rows[s].1 / 96) as u16,
|
||||||
width: cols[t].0 as u16,
|
cols[t].0 as u16,
|
||||||
height: (rows[s].0 / 96) as u16
|
(rows[s].0 / 96) as u16
|
||||||
};
|
];
|
||||||
let mut track_area: Option<Rect> = None;
|
let mut track_area: Option<[u16;4]> = None;
|
||||||
let mut scene_area: Option<Rect> = None;
|
let mut scene_area: Option<[u16;4]> = None;
|
||||||
let mut clip_area: Option<Rect> = None;
|
let mut clip_area: Option<[u16;4]> = None;
|
||||||
let area = match selected {
|
let area = match selected {
|
||||||
ArrangerFocus::Mix => {
|
ArrangerFocus::Mix => {
|
||||||
to.fill_bg(area, COLOR_BG0);
|
to.fill_bg(area, COLOR_BG0);
|
||||||
|
|
@ -136,13 +136,13 @@ impl<'a> Render<Tui> for CursorFocus<'a> {
|
||||||
area
|
area
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
if let Some(Rect { x, y, width, height }) = track_area {
|
if let Some([x, y, width, height]) = track_area {
|
||||||
to.fill_fg(Rect { x, y, width: 1, height }, COLOR_BG5);
|
to.fill_fg([x, y, 1, height], COLOR_BG5);
|
||||||
to.fill_fg(Rect { x: x + width, y, width: 1, height }, COLOR_BG5);
|
to.fill_fg([x + width, y, 1, height], COLOR_BG5);
|
||||||
}
|
}
|
||||||
if let Some(Rect { y, height, .. }) = scene_area {
|
if let Some([_, y, _, height]) = scene_area {
|
||||||
to.fill_ul(Rect { x: area.x, y: y - 1, width: area.width, height: 1 }, COLOR_BG5);
|
to.fill_ul([area.x(), y - 1, area.w(), 1], COLOR_BG5);
|
||||||
to.fill_ul(Rect { x: area.x, y: y + height - 1, width: area.width, height: 1 }, COLOR_BG5);
|
to.fill_ul([area.x(), y + height - 1, area.w(), 1], COLOR_BG5);
|
||||||
}
|
}
|
||||||
if let Some(clip_area) = clip_area {
|
if let Some(clip_area) = clip_area {
|
||||||
to.fill_bg(clip_area, COLOR_BG0);
|
to.fill_bg(clip_area, COLOR_BG0);
|
||||||
|
|
@ -158,35 +158,35 @@ impl<'a> Render<Tui> for CursorFocus<'a> {
|
||||||
struct TracksHeader<'a>(u16, &'a[(usize, usize)], &'a [Sequencer]);
|
struct TracksHeader<'a>(u16, &'a[(usize, usize)], &'a [Sequencer]);
|
||||||
|
|
||||||
impl<'a> Render<Tui> for TracksHeader<'a> {
|
impl<'a> Render<Tui> for TracksHeader<'a> {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let area = to.area();
|
let area = to.area();
|
||||||
let Self(offset, track_cols, tracks) = *self;
|
let Self(offset, track_cols, tracks) = *self;
|
||||||
let Rect { y, width, .. } = area;
|
let [x, y, width, _] = area;
|
||||||
for (track, (w, x)) in tracks.iter().zip(track_cols) {
|
for (track, (w, x)) in tracks.iter().zip(track_cols) {
|
||||||
let x = *x as u16;
|
let x = *x as u16;
|
||||||
if x > width {
|
if x > width {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
let name = track.name.read().unwrap();
|
let name = track.name.read().unwrap();
|
||||||
to.fill_bg(Rect { x: offset + x, y, width: *w as u16, height: 2 }, COLOR_BG1);
|
to.fill_bg([offset + x, y, *w as u16, 2], COLOR_BG1);
|
||||||
to.blit(&*name, offset + x + 1, y, Some(Style::default().white()))?;
|
to.blit(&*name, offset + x + 1, y, Some(Style::default().white()))?;
|
||||||
}
|
}
|
||||||
Ok(Some(Rect { x: area.x, y, width, height: 2 }))
|
Ok(Some([x, y, width, 2]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SceneRows<'a>(u16, &'a[(usize, usize)], &'a[(usize, usize)], &'a[Sequencer], &'a[Scene]);
|
struct SceneRows<'a>(u16, &'a[(usize, usize)], &'a[(usize, usize)], &'a[Sequencer], &'a[Scene]);
|
||||||
|
|
||||||
impl<'a> Render<Tui> for SceneRows<'a> {
|
impl<'a> Render<Tui> for SceneRows<'a> {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let area = to.area();
|
let area = to.area();
|
||||||
let Self(offset, track_cols, scene_rows, tracks, scenes) = *self;
|
let Self(offset, track_cols, scene_rows, tracks, scenes) = *self;
|
||||||
let black = Some(Style::default().fg(Nord::SEPARATOR));
|
let black = Some(Style::default().fg(Nord::SEPARATOR));
|
||||||
let Rect { mut y, height: _height, .. } = area;
|
let [_, mut y, _, _height] = area;
|
||||||
for (_, x) in track_cols.iter() {
|
for (_, x) in track_cols.iter() {
|
||||||
let x = *x as u16;
|
let x = *x as u16;
|
||||||
if x > 0 {
|
if x > 0 {
|
||||||
for y in area.y-2..y-2 {
|
for y in area.y()-2..y-2 {
|
||||||
to.blit(&"▎", x - 1, y, black)?;
|
to.blit(&"▎", x - 1, y, black)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -197,7 +197,7 @@ impl<'a> Render<Tui> for SceneRows<'a> {
|
||||||
//}
|
//}
|
||||||
let h = 1.max((pulses / 96) as u16);
|
let h = 1.max((pulses / 96) as u16);
|
||||||
SceneRow(tracks, scene, track_cols, offset)
|
SceneRow(tracks, scene, track_cols, offset)
|
||||||
.render(to.with_area(area.x, y, area.width, h))?;
|
.render(to.with_area(area.x(), y, area.w(), h))?;
|
||||||
y = y + h
|
y = y + h
|
||||||
}
|
}
|
||||||
Ok(Some(area))
|
Ok(Some(area))
|
||||||
|
|
@ -207,14 +207,14 @@ impl<'a> Render<Tui> for SceneRows<'a> {
|
||||||
struct SceneRow<'a>(&'a[Sequencer], &'a Scene, &'a[(usize, usize)], u16);
|
struct SceneRow<'a>(&'a[Sequencer], &'a Scene, &'a[(usize, usize)], u16);
|
||||||
|
|
||||||
impl<'a> Render<Tui> for SceneRow<'a> {
|
impl<'a> Render<Tui> for SceneRow<'a> {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let area = to.area();
|
let area = to.area();
|
||||||
let Self(tracks, scene, track_cols, offset) = self;
|
let Self(tracks, scene, track_cols, offset) = self;
|
||||||
let Rect { x, y, width, .. } = area;
|
let [x, y, width, _] = area;
|
||||||
let playing = scene.is_playing(tracks);
|
let playing = scene.is_playing(tracks);
|
||||||
to.blit(&if playing { "▶" } else { " " }, x, y, None)?;
|
to.blit(&if playing { "▶" } else { " " }, x, y, None)?;
|
||||||
to.blit(&*scene.name.read().unwrap(), x + 1, y, Some(Style::default().white()))?;
|
to.blit(&*scene.name.read().unwrap(), x + 1, y, Some(Style::default().white()))?;
|
||||||
to.fill_bg(Rect { x: x, y, width: offset.saturating_sub(1), height: area.height }, COLOR_BG1);
|
to.fill_bg([x, y, offset.saturating_sub(1), area.h()], COLOR_BG1);
|
||||||
for (track, (w, x)) in track_cols.iter().enumerate() {
|
for (track, (w, x)) in track_cols.iter().enumerate() {
|
||||||
let x = *x as u16 + offset;
|
let x = *x as u16 + offset;
|
||||||
if x > width {
|
if x > width {
|
||||||
|
|
@ -223,7 +223,7 @@ impl<'a> Render<Tui> for SceneRow<'a> {
|
||||||
if let (Some(track), Some(Some(clip))) = (
|
if let (Some(track), Some(Some(clip))) = (
|
||||||
tracks.get(track), scene.clips.get(track)
|
tracks.get(track), scene.clips.get(track)
|
||||||
) {
|
) {
|
||||||
SceneClip(track, *clip).render(to.with_area(x, y, *w as u16, area.height))?;
|
SceneClip(track, *clip).render(to.with_area(x, y, *w as u16, area.h()))?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(Some(area))
|
Ok(Some(area))
|
||||||
|
|
@ -233,14 +233,14 @@ impl<'a> Render<Tui> for SceneRow<'a> {
|
||||||
struct SceneClip<'a>(&'a Sequencer, usize);
|
struct SceneClip<'a>(&'a Sequencer, usize);
|
||||||
|
|
||||||
impl<'a> Render<Tui> for SceneClip<'a> {
|
impl<'a> Render<Tui> for SceneClip<'a> {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let area = to.area();
|
let area = to.area();
|
||||||
let Self(track, clip) = self;
|
let Self(track, clip) = self;
|
||||||
let style = Some(Style::default().white());
|
let style = Some(Style::default().white());
|
||||||
if let Some(phrase) = track.phrases.get(*clip) {
|
if let Some(phrase) = track.phrases.get(*clip) {
|
||||||
let phrase = phrase.read().unwrap();
|
let phrase = phrase.read().unwrap();
|
||||||
let name = phrase.name.read().unwrap();
|
let name = phrase.name.read().unwrap();
|
||||||
to.blit(&format!("{clip:02} {name}"), area.x + 1, area.y, style)?;
|
to.blit(&format!("{clip:02} {name}"), area.x() + 1, area.y(), style)?;
|
||||||
to.fill_bg(area, if track.sequence == Some(*clip) {
|
to.fill_bg(area, if track.sequence == Some(*clip) {
|
||||||
Nord::PLAYING
|
Nord::PLAYING
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
impl<'a> Render<Tui> for Sequencer {
|
impl<'a> Render<Tui> for Sequencer {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
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)?;
|
Corners(Style::default().green().not_dim()).draw(to)?;
|
||||||
|
|
|
||||||
|
|
@ -49,8 +49,8 @@ const STYLE_VALUE: Option<Style> = Some(Style {
|
||||||
struct SequenceName<'a>(&'a Sequencer);
|
struct SequenceName<'a>(&'a Sequencer);
|
||||||
|
|
||||||
impl<'a> Render<Tui> for SequenceName<'a> {
|
impl<'a> Render<Tui> for SequenceName<'a> {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let Rect { x, y, .. } = to.area();
|
let [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.with_rect(frame))?;
|
Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(frame))?;
|
||||||
to.blit(&"Name:", x + 1, y + 1, STYLE_LABEL)?;
|
to.blit(&"Name:", x + 1, y + 1, STYLE_LABEL)?;
|
||||||
|
|
@ -62,8 +62,8 @@ impl<'a> Render<Tui> for SequenceName<'a> {
|
||||||
struct SequenceRange;
|
struct SequenceRange;
|
||||||
|
|
||||||
impl<'a> Render<Tui> for SequenceRange {
|
impl<'a> Render<Tui> for SequenceRange {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let Rect { x, y, .. } = to.area();
|
let [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.with_rect(frame))?;
|
Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(frame))?;
|
||||||
to.blit(&"Start: ", x + 1, y + 1, STYLE_LABEL)?;
|
to.blit(&"Start: ", x + 1, y + 1, STYLE_LABEL)?;
|
||||||
|
|
@ -77,8 +77,8 @@ impl<'a> Render<Tui> for SequenceRange {
|
||||||
struct SequenceLoopRange;
|
struct SequenceLoopRange;
|
||||||
|
|
||||||
impl<'a> Render<Tui> for SequenceLoopRange {
|
impl<'a> Render<Tui> for SequenceLoopRange {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let Rect { x, y, .. } = to.area();
|
let [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.with_rect(range))?;
|
Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(range))?;
|
||||||
to.blit(&"Loop [ ]", x + 1, y + 1, STYLE_LABEL)?;
|
to.blit(&"Loop [ ]", x + 1, y + 1, STYLE_LABEL)?;
|
||||||
|
|
@ -93,8 +93,8 @@ impl<'a> Render<Tui> for SequenceLoopRange {
|
||||||
struct SequenceNoteRange;
|
struct SequenceNoteRange;
|
||||||
|
|
||||||
impl<'a> Render<Tui> for SequenceNoteRange {
|
impl<'a> Render<Tui> for SequenceNoteRange {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let Rect { x, y, .. } = to.area();
|
let [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.with_rect(range))?;
|
Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(range))?;
|
||||||
to.blit(&"Notes: ", x + 1, y + 1, STYLE_LABEL)?;
|
to.blit(&"Notes: ", x + 1, y + 1, STYLE_LABEL)?;
|
||||||
|
|
@ -111,7 +111,7 @@ impl<'a> Render<Tui> for SequenceNoteRange {
|
||||||
struct SequenceKeys<'a>(&'a Sequencer);
|
struct SequenceKeys<'a>(&'a Sequencer);
|
||||||
|
|
||||||
impl<'a> Render<Tui> for SequenceKeys<'a> {
|
impl<'a> Render<Tui> for SequenceKeys<'a> {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let area = to.area();
|
let area = to.area();
|
||||||
if area.height < 2 {
|
if area.height < 2 {
|
||||||
return Ok(Some(area))
|
return Ok(Some(area))
|
||||||
|
|
@ -135,7 +135,7 @@ impl<'a> Render<Tui> for SequenceKeys<'a> {
|
||||||
struct SequenceNotes<'a>(&'a Sequencer);
|
struct SequenceNotes<'a>(&'a Sequencer);
|
||||||
|
|
||||||
impl<'a> Render<Tui> for SequenceNotes<'a> {
|
impl<'a> Render<Tui> for SequenceNotes<'a> {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let area = to.area();
|
let area = to.area();
|
||||||
if area.height < 2 {
|
if area.height < 2 {
|
||||||
return Ok(Some(area))
|
return Ok(Some(area))
|
||||||
|
|
@ -164,7 +164,7 @@ impl<'a> Render<Tui> for SequenceNotes<'a> {
|
||||||
struct SequenceCursor<'a>(&'a Sequencer);
|
struct SequenceCursor<'a>(&'a Sequencer);
|
||||||
|
|
||||||
impl<'a> Render<Tui> for SequenceCursor<'a> {
|
impl<'a> Render<Tui> for SequenceCursor<'a> {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let area = to.area();
|
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 = area.x + Sequencer::H_KEYS_OFFSET as u16 + time as u16;
|
let x = area.x + Sequencer::H_KEYS_OFFSET as u16 + time as u16;
|
||||||
|
|
@ -180,7 +180,7 @@ impl<'a> Render<Tui> for SequenceCursor<'a> {
|
||||||
struct SequenceZoom<'a>(&'a Sequencer);
|
struct SequenceZoom<'a>(&'a Sequencer);
|
||||||
|
|
||||||
impl<'a> Render<Tui> for SequenceZoom<'a> {
|
impl<'a> Render<Tui> for SequenceZoom<'a> {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let area = to.area();
|
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 = area.x + area.width - 1 - quant.len() as u16;
|
let quant_x = area.x + area.width - 1 - quant.len() as u16;
|
||||||
|
|
@ -192,13 +192,13 @@ impl<'a> Render<Tui> for SequenceZoom<'a> {
|
||||||
struct SequenceTimer<'a>(&'a Sequencer, Arc<RwLock<Phrase>>);
|
struct SequenceTimer<'a>(&'a Sequencer, Arc<RwLock<Phrase>>);
|
||||||
|
|
||||||
impl<'a> Render<Tui> for SequenceTimer<'a> {
|
impl<'a> Render<Tui> for SequenceTimer<'a> {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let area = to.area();
|
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, .. } = area;
|
let [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 {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use crate::*;
|
||||||
const CORNERS: Corners = Corners(NOT_DIM_GREEN);
|
const CORNERS: Corners = Corners(NOT_DIM_GREEN);
|
||||||
|
|
||||||
impl Render<Tui> for TransportToolbar {
|
impl Render<Tui> for TransportToolbar {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let mut area = to.area();
|
let mut area = to.area();
|
||||||
area.height = 2;
|
area.height = 2;
|
||||||
let area = Split::right()
|
let area = Split::right()
|
||||||
|
|
@ -22,9 +22,9 @@ impl Render<Tui> for TransportToolbar {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render<Tui> for TransportPlayPauseButton {
|
impl Render<Tui> for TransportPlayPauseButton {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let area = to.area();
|
let area = to.area();
|
||||||
let Rect { x, y, .. } = area;
|
let [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(),
|
||||||
|
|
@ -51,9 +51,9 @@ impl Render<Tui> for TransportPlayPauseButton {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render<Tui> for TransportBPM {
|
impl Render<Tui> for TransportBPM {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let area = to.area();
|
let area = to.area();
|
||||||
let Rect { x, y, .. } = area;
|
let [x, y, ..] = area;
|
||||||
let Self { value, focused } = self;
|
let Self { value, focused } = self;
|
||||||
to.blit(&"BPM", x, y, Some(NOT_DIM))?;
|
to.blit(&"BPM", x, y, Some(NOT_DIM))?;
|
||||||
let bpm = format!("{}.{:03}", value, (value * 1000.0) % 1000.0);
|
let bpm = format!("{}.{:03}", value, (value * 1000.0) % 1000.0);
|
||||||
|
|
@ -70,8 +70,8 @@ impl Render<Tui> for TransportBPM {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render<Tui> for TransportQuantize {
|
impl Render<Tui> for TransportQuantize {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let Rect { x, y, .. } = to.area();
|
let [x, y, ..] = to.area();
|
||||||
let Self { value, focused } = self;
|
let Self { value, focused } = self;
|
||||||
to.blit(&"QUANT", x, y, Some(NOT_DIM))?;
|
to.blit(&"QUANT", x, y, Some(NOT_DIM))?;
|
||||||
let name = ppq_to_name(*value as usize);
|
let name = ppq_to_name(*value as usize);
|
||||||
|
|
@ -88,8 +88,8 @@ impl Render<Tui> for TransportQuantize {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render<Tui> for TransportSync {
|
impl Render<Tui> for TransportSync {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let Rect { x, y, .. } = to.area();
|
let [x, y, ..] = to.area();
|
||||||
let Self { value, focused } = self;
|
let Self { value, focused } = self;
|
||||||
to.blit(&"SYNC", x, y, Some(NOT_DIM))?;
|
to.blit(&"SYNC", x, y, Some(NOT_DIM))?;
|
||||||
let name = ppq_to_name(*value as usize);
|
let name = ppq_to_name(*value as usize);
|
||||||
|
|
@ -106,8 +106,8 @@ impl Render<Tui> for TransportSync {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render<Tui> for TransportClock {
|
impl Render<Tui> for TransportClock {
|
||||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||||
let Rect { x, y, width, .. } = to.area();
|
let [x, y, width, _] = to.area();
|
||||||
let Self { frame: _frame, pulse, ppq, usecs, focused } = self;
|
let Self { frame: _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);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue