wip: replacing Rect with [u16;4] in mixer and sequencer

This commit is contained in:
🪞👃🪞 2024-09-07 12:50:52 +03:00
parent fa739a49b2
commit 06f8bd1116
14 changed files with 106 additions and 106 deletions

View file

@ -31,7 +31,7 @@ impl<E: Engine> Process for Mixer<E> {
}
}
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();
for channel in self.tracks.iter() {
tracks = tracks.add_ref(channel)

View file

@ -16,9 +16,9 @@ impl Handle<Tui> for Plugin {
}
process!(Plugin = Plugin::process);
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 Rect { x, y, height, .. } = area;
let [x, y, _, height] = area;
let mut width = 20u16;
match &self.plugin {
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)?;
Ok(Some(Rect { width, ..to.area() }))
draw_header(self, to, x, y, width)?;
Ok(Some([x, y, width, height]))
}
}

View file

@ -23,7 +23,7 @@ pub struct AddSampleModal {
exit!(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();
to.make_dim();
let area = center_box(

View file

@ -1,13 +1,13 @@
use crate::*;
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)
}
}
pub fn tui_render_sampler (sampler: &Sampler, to: &mut Tui) -> Perhaps<Rect> {
let Rect { x, y, height, .. } = to.area();
pub fn tui_render_sampler (sampler: &Sampler, to: &mut Tui) -> Perhaps<[u16;4]> {
let [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()))?;
@ -29,7 +29,7 @@ pub fn tui_render_sampler (sampler: &Sampler, to: &mut Tui) -> Perhaps<Rect> {
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 }))
Ok(Some([x, y, (width as u16).min(to.area().w()), height]))
}
fn draw_sample (

View file

@ -2,7 +2,7 @@ use crate::*;
use tek_core::Direction;
impl Render<Tui> for Track<Tui> {
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
TrackView {
chain: Some(&self),
direction: tek_core::Direction::Right,
@ -31,7 +31,7 @@ pub struct TrackView<'a, E: Engine> {
pub entered: bool,
}
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();
if let Some(chain) = self.chain {
match self.direction {
@ -50,7 +50,7 @@ impl<'a> Render<Tui> for TrackView<'a, Tui> {
}
Ok(Some(area))
} else {
let Rect { x, y, width, height } = area;
let [x, y, width, height] = area;
let label = "No chain selected";
let x = x + (width - label.len() as u16) / 2;
let y = y + height / 2;