mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
fine detour!
This commit is contained in:
parent
4f6cb7cb8e
commit
0733742685
8 changed files with 68 additions and 58 deletions
|
|
@ -192,6 +192,12 @@ impl ArrangementCommand {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'state> Context<'state, TrackCommand> for Arrangement {
|
||||
fn get <'source> (&'state self, iter: &mut TokenIter<'source>) -> Option<TrackCommand> {
|
||||
Context::get(&self, iter)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'state> Context<'state, MidiInputCommand> for Arrangement {
|
||||
fn get <'source> (&'state self, iter: &mut TokenIter<'source>) -> Option<MidiInputCommand> {
|
||||
Context::get(&self, iter)
|
||||
|
|
|
|||
|
|
@ -47,6 +47,12 @@ has!(Vec<JackMidiOut>: |self: Arrangement|self.midi_outs);
|
|||
has!(Vec<Scene>: |self: Arrangement|self.scenes);
|
||||
has!(Vec<Track>: |self: Arrangement|self.tracks);
|
||||
has!(Measure<TuiOut>: |self: Arrangement|self.size);
|
||||
maybe_has!(Track: |self: Arrangement|
|
||||
{ Has::<Selection>::get(self).track().map(|index|Has::<Vec<Track>>::get(self).get(index)).flatten() };
|
||||
{ Has::<Selection>::get(self).track().map(|index|Has::<Vec<Track>>::get_mut(self).get_mut(index)).flatten() });
|
||||
maybe_has!(Scene: |self: Arrangement|
|
||||
{ Has::<Selection>::get(self).track().map(|index|Has::<Vec<Scene>>::get(self).get(index)).flatten() };
|
||||
{ Has::<Selection>::get(self).track().map(|index|Has::<Vec<Scene>>::get_mut(self).get_mut(index)).flatten() });
|
||||
|
||||
impl Arrangement {
|
||||
/// Width of display
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
use crate::*;
|
||||
|
||||
impl<'state> Context<'state, TrackCommand> for Arrangement {
|
||||
fn get <'source> (&'state self, iter: &mut TokenIter<'source>) -> Option<TrackCommand> {
|
||||
Context::get(&self, iter)
|
||||
impl<T: MaybeHas<Track>> HasTrack for T {
|
||||
fn track (&self) -> Option<&Track> {
|
||||
self.get()
|
||||
}
|
||||
fn track_mut (&mut self) -> Option<&mut Track> {
|
||||
self.get_mut()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -152,6 +155,38 @@ impl Track {
|
|||
pub trait HasTrack {
|
||||
fn track (&self) -> Option<&Track>;
|
||||
fn track_mut (&mut self) -> Option<&mut Track>;
|
||||
fn view_midi_ins_status (&self, theme: ItemTheme) -> impl Content<TuiOut> {
|
||||
self.track().map(|track|{
|
||||
let ins = track.sequencer.midi_ins.len() as u16;
|
||||
Fixed::xy(20, 1 + ins, Outer(true, Style::default().fg(Tui::g(96))).enclose(
|
||||
Fixed::xy(20, 1 + ins, FieldV(theme, format!("MIDI ins: "),
|
||||
Map::south(1, ||track.sequencer.midi_ins.iter(),
|
||||
|port, index|Fill::x(Align::w(format!(" {index} {}", port.name()))))))))})
|
||||
}
|
||||
fn view_midi_outs_status (&self, theme: ItemTheme) -> impl Content<TuiOut> {
|
||||
self.track().map(|track|{
|
||||
let outs = track.sequencer.midi_outs.len() as u16;
|
||||
Fixed::xy(20, 1 + outs, Outer(true, Style::default().fg(Tui::g(96))).enclose(
|
||||
Fixed::xy(20, 1 + outs, FieldV(theme, format!("MIDI outs: "),
|
||||
Map::south(1, ||track.sequencer.midi_outs.iter(),
|
||||
|port, index|Fill::x(Align::w(format!(" {index} {}", port.name()))))))))})
|
||||
}
|
||||
fn view_audio_ins_status (&self, theme: ItemTheme) -> impl Content<TuiOut> {
|
||||
self.track().and_then(|track|track.devices.get(0)).map(|device|{
|
||||
let ins = device.audio_ins().len() as u16;
|
||||
Fixed::xy(20, 1 + ins, Outer(true, Style::default().fg(Tui::g(96))).enclose(
|
||||
Fixed::xy(20, 1 + ins, FieldV(theme, format!("Audio ins: "),
|
||||
Map::south(1, ||device.audio_ins().iter(),
|
||||
|port, index|Fill::x(Align::w(format!(" {index} {}", port.name()))))))))})
|
||||
}
|
||||
fn view_audio_outs_status (&self, theme: ItemTheme) -> impl Content<TuiOut> {
|
||||
self.track().and_then(|track|track.devices.last()).map(|device|{
|
||||
let outs = device.audio_outs().len() as u16;
|
||||
Fixed::xy(20, 1 + outs, Outer(true, Style::default().fg(Tui::g(96))).enclose(
|
||||
Fixed::xy(20, 1 + outs, FieldV(theme, format!("Audio outs: "),
|
||||
Map::south(1, ||device.audio_outs().iter(),
|
||||
|port, index|Fill::x(Align::w(format!(" {index} {}", port.name()))))))))})
|
||||
}
|
||||
}
|
||||
|
||||
//impl<T: Has<Option<Track>>> HasTrack for T {
|
||||
|
|
@ -162,14 +197,3 @@ pub trait HasTrack {
|
|||
//self.get_mut().as_mut()
|
||||
//}
|
||||
//}
|
||||
|
||||
impl<T: Has<Vec<Track>> + Has<Selection>> HasTrack for T {
|
||||
fn track (&self) -> Option<&Track> {
|
||||
let index = Has::<Selection>::get(self).track()?;
|
||||
Has::<Vec<Track>>::get(self).get(index)
|
||||
}
|
||||
fn track_mut (&mut self) -> Option<&mut Track> {
|
||||
let index = Has::<Selection>::get(self).track()?;
|
||||
Has::<Vec<Track>>::get_mut(self).get_mut(index)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ pub(crate) use std::path::PathBuf;
|
|||
pub(crate) use std::error::Error;
|
||||
pub(crate) use std::ffi::OsString;
|
||||
|
||||
pub(crate) use ::tengri::{from, Usually, Perhaps, Has};
|
||||
pub(crate) use ::tengri::{from, has, maybe_has, Usually, Perhaps, Has, MaybeHas};
|
||||
pub(crate) use ::tengri::{dsl::*, input::*, output::*, tui::{*, ratatui::prelude::*}};
|
||||
pub(crate) use ::tek_engine::*;
|
||||
pub(crate) use ::tek_engine::midi::{u7, LiveEvent, MidiMessage};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue