app trait impls

This commit is contained in:
🪞👃🪞 2025-01-13 20:23:10 +01:00
parent af2e237b94
commit 93fa3c26b4
4 changed files with 156 additions and 137 deletions

View file

@ -0,0 +1,22 @@
use crate::*;
pub trait HasSampler {
fn sampler (&self) -> &Option<Sampler>;
fn sampler_mut (&mut self) -> &mut Option<Sampler>;
fn sample_index (&self) -> usize;
fn view_sample <'a> (&'a self, compact: bool) -> impl Content<TuiOut> + 'a {
self.sampler().as_ref().map(|sampler|Max::y(
if compact { 0u16 } else { 5 }.into(),
Fill::x(sampler.viewer(self.sample_index()))
))
}
fn view_sampler <'a> (&'a self, compact: bool, editor: &Option<MidiEditor>) -> impl Content<TuiOut> + 'a {
self.sampler().as_ref().map(|sampler|Fixed::x(
if compact { 4u16 } else { 40 }.into(),
Push::y(
if compact { 1u16 } else { 0 }.into(),
editor.as_ref().map(|e|Fill::y(sampler.list(compact, e)))
)
))
}
}

View file

@ -1,6 +1,7 @@
mod sampler; pub use self::sampler::*;
mod sampler_tui; pub use self::sampler_tui::*;
mod sampler_cmd; pub use self::sampler_cmd::*;
mod has_sampler; pub use self::has_sampler::*;
pub(crate) use ::tek_jack::{*, jack::*};
pub(crate) use ::tek_midi::{*, midly::{*, live::*, num::*}};