mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-09-18 12:56:42 +02:00
refactor: Mode, View, Bind
This commit is contained in:
parent
51faa82d74
commit
701a651fbd
21 changed files with 901 additions and 880 deletions
|
|
@ -55,9 +55,13 @@ impl Track {
|
|||
) -> impl Draw<Tui> + 'a {
|
||||
view_track_per(tracks, callback)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "sampler")]
|
||||
impl Track {
|
||||
|
||||
/// Create a new track connecting the [Sequencer] to a [Sampler].
|
||||
#[cfg(feature = "sampler")] pub fn new_with_sampler (
|
||||
pub fn new_with_sampler (
|
||||
name: &impl AsRef<str>,
|
||||
color: Option<ItemTheme>,
|
||||
jack: &Jack<'static>,
|
||||
|
|
@ -78,7 +82,7 @@ impl Track {
|
|||
Ok(track)
|
||||
}
|
||||
|
||||
#[cfg(feature = "sampler")] pub fn sampler (&self, mut nth: usize) -> Option<&Sampler> {
|
||||
pub fn sampler (&self, mut nth: usize) -> Option<&Sampler> {
|
||||
for device in self.devices.iter() {
|
||||
match device {
|
||||
Device::Sampler(s) => if nth == 0 { return Some(s); } else { nth -= 1; },
|
||||
|
|
@ -88,7 +92,7 @@ impl Track {
|
|||
None
|
||||
}
|
||||
|
||||
#[cfg(feature = "sampler")] pub fn sampler_mut (&mut self, mut nth: usize) -> Option<&mut Sampler> {
|
||||
pub fn sampler_mut (&mut self, mut nth: usize) -> Option<&mut Sampler> {
|
||||
for device in self.devices.iter_mut() {
|
||||
match device {
|
||||
Device::Sampler(s) => if nth == 0 { return Some(s); } else { nth -= 1; },
|
||||
|
|
@ -153,22 +157,22 @@ pub trait HasTrack: AsRefOpt<Track> + AsMutOpt<Track> {
|
|||
|
||||
#[cfg(feature = "port")]
|
||||
fn view_midi_ins_status <'a> (&'a self, theme: ItemTheme) -> impl Draw<Tui> + 'a {
|
||||
crate::view::view_midi_ins_status(theme, self.track())
|
||||
view_midi_ins_status(theme, self.track())
|
||||
}
|
||||
|
||||
#[cfg(feature = "port")]
|
||||
fn view_midi_outs_status (&self, theme: ItemTheme) -> impl Draw<Tui> + '_ {
|
||||
crate::view::view_midi_outs_status(theme, self.track())
|
||||
view_midi_outs_status(theme, self.track())
|
||||
}
|
||||
|
||||
#[cfg(feature = "port")]
|
||||
fn view_audio_ins_status (&self, theme: ItemTheme) -> impl Draw<Tui> {
|
||||
crate::view::view_audio_ins_status(theme, self.track())
|
||||
view_audio_ins_status(theme, self.track())
|
||||
}
|
||||
|
||||
#[cfg(feature = "port")]
|
||||
fn view_audio_outs_status (&self, theme: ItemTheme) -> impl Draw<Tui> {
|
||||
crate::view::view_audio_outs_status(theme, self.track())
|
||||
view_audio_outs_status(theme, self.track())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -179,13 +183,13 @@ pub trait HasTrackScroll: HasTracks {
|
|||
pub trait TracksView: ScenesView + HasMidiIns + HasMidiOuts + HasTrackScroll {
|
||||
/// Draw name of each track
|
||||
fn view_track_names (&self, theme: ItemTheme) -> impl Draw<Tui> {
|
||||
crate::view::view_track_names(
|
||||
view_track_names(
|
||||
theme, self.tracks_with_sizes(), self.tracks().len(), self.scenes().len(), self.selection()
|
||||
)
|
||||
}
|
||||
/// Draw outputs per track
|
||||
fn view_track_outputs <'a> (&'a self, theme: ItemTheme, _h: u16) -> impl Draw<Tui> {
|
||||
crate::view::view_track_outputs(
|
||||
view_track_outputs(
|
||||
theme, self.tracks_with_sizes(), self.midi_outs().iter()
|
||||
)
|
||||
}
|
||||
|
|
@ -195,7 +199,7 @@ pub trait TracksView: ScenesView + HasMidiIns + HasMidiOuts + HasTrackScroll {
|
|||
for track in self.tracks().iter() {
|
||||
h = h.max(track.sequencer.midi_ins.len() as u16);
|
||||
}
|
||||
crate::view::view_track_inputs(theme, self.tracks_with_sizes(), h)
|
||||
view_track_inputs(theme, self.tracks_with_sizes(), h)
|
||||
}
|
||||
/// Iterate over tracks with their corresponding sizes.
|
||||
fn tracks_with_sizes (&self) -> impl TracksSizes<'_> {
|
||||
|
|
@ -247,19 +251,19 @@ impl_as_mut!(Vec<Track>: |self: App| self.project.as_mut());
|
|||
impl Arrangement {
|
||||
|
||||
pub fn view_inputs (&self, _theme: ItemTheme) -> impl Draw<Tui> + '_ {
|
||||
crate::view::view_inputs(
|
||||
view_inputs(
|
||||
self.tracks_with_sizes(), self.midi_ins().as_slice()
|
||||
)
|
||||
}
|
||||
|
||||
pub fn view_outputs (&self, theme: ItemTheme) -> impl Draw<Tui> {
|
||||
crate::view::view_outputs(
|
||||
view_outputs(
|
||||
theme, self.tracks_with_sizes(), self.midi_outs(), self.outputs_height()
|
||||
)
|
||||
}
|
||||
|
||||
pub fn view_track_devices (&self, theme: ItemTheme) -> impl Draw<Tui> {
|
||||
crate::view::view_track_devices(
|
||||
view_track_devices(
|
||||
theme, self.tracks_with_sizes(), self.track(), self.devices_height()
|
||||
)
|
||||
}
|
||||
|
|
@ -334,3 +338,13 @@ impl Arrangement {
|
|||
Ok((index, &mut self.tracks_mut()[index]))
|
||||
}
|
||||
}
|
||||
|
||||
impl HasTrackScroll for App {
|
||||
fn track_scroll (&self) -> usize {
|
||||
self.project.track_scroll()
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn track_width (_index: usize, track: &Track) -> u16 {
|
||||
track.width as u16
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue