mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
app trait impls
This commit is contained in:
parent
af2e237b94
commit
93fa3c26b4
4 changed files with 156 additions and 137 deletions
22
sampler/src/has_sampler.rs
Normal file
22
sampler/src/has_sampler.rs
Normal 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)))
|
||||
)
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
@ -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::*}};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue