mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-04-04 05:10:44 +02:00
well, 55 errors until up to date
and then we fix
This commit is contained in:
parent
0577309b19
commit
7ff1d989a9
5 changed files with 333 additions and 344 deletions
116
app/tek_trait.rs
116
app/tek_trait.rs
|
|
@ -119,7 +119,7 @@ pub trait MidiRange: TimeRange + NoteRange {}
|
|||
/// can be clocked in microseconds with f64 without losing precision.
|
||||
pub trait TimeUnit: InteriorMutable<f64> {}
|
||||
|
||||
pub trait HasClipsSize { fn clips_size (&self) -> &Measure<TuiOut>; }
|
||||
pub trait HasClipsSize { fn clips_size (&self) -> &Measure<Tui>; }
|
||||
|
||||
pub trait HasMidiClip {
|
||||
fn clip (&self) -> Option<Arc<RwLock<MidiClip>>>;
|
||||
|
|
@ -327,16 +327,16 @@ pub trait HasTracks: AsRef<Vec<Track>> + AsMut<Vec<Track>> {
|
|||
pub trait HasTrack: AsRefOpt<Track> + AsMutOpt<Track> {
|
||||
fn track (&self) -> Option<&Track> { self.as_ref_opt() }
|
||||
fn track_mut (&mut self) -> Option<&mut Track> { self.as_mut_opt() }
|
||||
#[cfg(feature = "port")] fn view_midi_ins_status <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> + 'a {
|
||||
#[cfg(feature = "port")] fn view_midi_ins_status <'a> (&'a self, theme: ItemTheme) -> impl Draw<Tui> + 'a {
|
||||
self.track().map(move|track|view_ports_status(theme, "MIDI ins: ", &track.sequencer.midi_ins))
|
||||
}
|
||||
#[cfg(feature = "port")] fn view_midi_outs_status (&self, theme: ItemTheme) -> impl Content<TuiOut> + '_ {
|
||||
#[cfg(feature = "port")] fn view_midi_outs_status (&self, theme: ItemTheme) -> impl Draw<Tui> + '_ {
|
||||
self.track().map(move|track|view_ports_status(theme, "MIDI outs: ", &track.sequencer.midi_outs))
|
||||
}
|
||||
#[cfg(feature = "port")] fn view_audio_ins_status (&self, theme: ItemTheme) -> impl Content<TuiOut> {
|
||||
#[cfg(feature = "port")] fn view_audio_ins_status (&self, theme: ItemTheme) -> impl Draw<Tui> {
|
||||
self.track().map(move|track|view_ports_status(theme, "Audio ins: ", &track.audio_ins()))
|
||||
}
|
||||
#[cfg(feature = "port")] fn view_audio_outs_status (&self, theme: ItemTheme) -> impl Content<TuiOut> {
|
||||
#[cfg(feature = "port")] fn view_audio_outs_status (&self, theme: ItemTheme) -> impl Draw<Tui> {
|
||||
self.track().map(move|track|view_ports_status(theme, "Audio outs:", &track.audio_outs()))
|
||||
}
|
||||
}
|
||||
|
|
@ -379,7 +379,7 @@ pub trait HasPlayClip: HasClock {
|
|||
*self.reset_mut() = true;
|
||||
}
|
||||
|
||||
fn play_status (&self) -> impl Content<TuiOut> {
|
||||
fn play_status (&self) -> impl Draw<Tui> {
|
||||
let (name, color): (Arc<str>, ItemTheme) = if let Some((_, Some(clip))) = self.play_clip() {
|
||||
let MidiClip { ref name, color, .. } = *clip.read().unwrap();
|
||||
(name.clone(), color)
|
||||
|
|
@ -389,10 +389,10 @@ pub trait HasPlayClip: HasClock {
|
|||
let time: String = self.pulses_since_start_looped()
|
||||
.map(|(times, time)|format!("{:>3}x {:>}", times+1.0, self.clock().timebase.format_beats_1(time)))
|
||||
.unwrap_or_else(||String::from(" ")).into();
|
||||
FieldV(color, "Now:", format!("{} {}", time, name))
|
||||
field_v(color, "Now:", format!("{} {}", time, name))
|
||||
}
|
||||
|
||||
fn next_status (&self) -> impl Content<TuiOut> {
|
||||
fn next_status (&self) -> impl Draw<Tui> {
|
||||
let mut time: Arc<str> = String::from("--.-.--").into();
|
||||
let mut name: Arc<str> = String::from("").into();
|
||||
let mut color = ItemTheme::G[64];
|
||||
|
|
@ -425,7 +425,7 @@ pub trait HasPlayClip: HasClock {
|
|||
name = "Stop".to_string().into();
|
||||
}
|
||||
};
|
||||
FieldV(color, "Next:", format!("{} {}", time, name))
|
||||
field_v(color, "Next:", format!("{} {}", time, name))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -489,7 +489,7 @@ pub trait MidiRecord: MidiMonitor + HasClock + HasPlayClip {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait MidiViewer: Measured<TuiOut> + MidiRange + MidiPoint + Debug + Send + Sync {
|
||||
pub trait MidiViewer: Measured<Tui> + MidiRange + MidiPoint + Debug + Send + Sync {
|
||||
fn buffer_size (&self, clip: &MidiClip) -> (usize, usize);
|
||||
fn redraw (&self);
|
||||
fn clip (&self) -> &Option<Arc<RwLock<MidiClip>>>;
|
||||
|
|
@ -557,20 +557,20 @@ pub trait MidiViewer: Measured<TuiOut> + MidiRange + MidiPoint + Debug + Send +
|
|||
pub trait ClipsView: TracksView + ScenesView {
|
||||
|
||||
fn view_scenes_clips <'a> (&'a self)
|
||||
-> impl Content<TuiOut> + 'a
|
||||
-> impl Draw<Tui> + 'a
|
||||
{
|
||||
self.clips_size().of(Fill::XY(Bsp::a(
|
||||
Fill::XY(Align::se(Tui::fg(Green, format!("{}x{}", self.clips_size().w(), self.clips_size().h())))),
|
||||
Thunk::new(|to: &mut TuiOut|for (
|
||||
self.clips_size().of(wh_full(above(
|
||||
wh_full(origin_se(Tui::fg(Green, format!("{}x{}", self.clips_size().w(), self.clips_size().h())))),
|
||||
Thunk::new(|to: &mut Tui|for (
|
||||
track_index, track, _, _
|
||||
) in self.tracks_with_sizes() {
|
||||
to.place(&Fixed::X(track.width as u16,
|
||||
Fill::Y(self.view_track_clips(track_index, track))))
|
||||
to.place(&w_exact(track.width as u16,
|
||||
h_full(self.view_track_clips(track_index, track))))
|
||||
}))))
|
||||
}
|
||||
|
||||
fn view_track_clips <'a> (&'a self, track_index: usize, track: &'a Track) -> impl Content<TuiOut> + 'a {
|
||||
Thunk::new(move|to: &mut TuiOut|for (
|
||||
fn view_track_clips <'a> (&'a self, track_index: usize, track: &'a Track) -> impl Draw<Tui> + 'a {
|
||||
Thunk::new(move|to: &mut Tui|for (
|
||||
scene_index, scene, ..
|
||||
) in self.scenes_with_sizes() {
|
||||
let (name, theme): (Arc<str>, ItemTheme) = if let Some(Some(clip)) = &scene.clips.get(track_index) {
|
||||
|
|
@ -609,14 +609,14 @@ pub trait ClipsView: TracksView + ScenesView {
|
|||
Self::H_SCENE as usize
|
||||
} as u16;
|
||||
|
||||
to.place(&Fixed::XY(w, y, Bsp::b(
|
||||
Fill::XY(Outer(true, Style::default().fg(outline))),
|
||||
Fill::XY(Bsp::b(
|
||||
Bsp::b(
|
||||
Tui::fg_bg(outline, bg, Fill::XY("")),
|
||||
Fill::XY(Align::nw(Tui::fg_bg(fg, bg, Tui::bold(true, name)))),
|
||||
to.place(&wh_exact(w, y, below(
|
||||
wh_full(Outer(true, Style::default().fg(outline))),
|
||||
wh_full(below(
|
||||
below(
|
||||
Tui::fg_bg(outline, bg, wh_full("")),
|
||||
wh_full(origin_nw(Tui::fg_bg(fg, bg, Tui::bold(true, name)))),
|
||||
),
|
||||
Fill::XY(When::new(self.selection().track() == Some(track_index)
|
||||
wh_full(when(self.selection().track() == Some(track_index)
|
||||
&& self.selection().scene() == Some(scene_index)
|
||||
&& self.is_editing(), self.editor())))))));
|
||||
})
|
||||
|
|
@ -624,7 +624,7 @@ pub trait ClipsView: TracksView + ScenesView {
|
|||
|
||||
}
|
||||
|
||||
pub trait TracksView: ScenesView + HasMidiIns + HasMidiOuts + HasTrackScroll + Measured<TuiOut> {
|
||||
pub trait TracksView: ScenesView + HasMidiIns + HasMidiOuts + HasTrackScroll + Measured<Tui> {
|
||||
|
||||
fn tracks_width_available (&self) -> u16 {
|
||||
(self.measure_width() as u16).saturating_sub(40)
|
||||
|
|
@ -647,68 +647,68 @@ pub trait TracksView: ScenesView + HasMidiIns + HasMidiOuts + HasTrackScroll + M
|
|||
})
|
||||
}
|
||||
|
||||
fn view_track_names (&self, theme: ItemTheme) -> impl Content<TuiOut> {
|
||||
fn view_track_names (&self, theme: ItemTheme) -> impl Draw<Tui> {
|
||||
let track_count = self.tracks().len();
|
||||
let scene_count = self.scenes().len();
|
||||
let selected = self.selection();
|
||||
let button = Bsp::s(
|
||||
let button = south(
|
||||
button_3("t", "rack ", format!("{}{track_count}", selected.track()
|
||||
.map(|track|format!("{track}/")).unwrap_or_default()), false),
|
||||
button_3("s", "cene ", format!("{}{scene_count}", selected.scene()
|
||||
.map(|scene|format!("{scene}/")).unwrap_or_default()), false));
|
||||
let button_2 = Bsp::s(
|
||||
let button_2 = south(
|
||||
button_2("T", "+", false),
|
||||
button_2("S", "+", false));
|
||||
view_track_row_section(theme, button, button_2, Tui::bg(theme.darker.rgb,
|
||||
Fixed::Y(2, Thunk::new(|to: &mut TuiOut|{
|
||||
h_exact(2, Thunk::new(|to: &mut Tui|{
|
||||
for (index, track, x1, _x2) in self.tracks_with_sizes() {
|
||||
to.place(&Push::X(x1 as u16, Fixed::X(track_width(index, track),
|
||||
to.place(&x_push(x1 as u16, w_exact(track_width(index, track),
|
||||
Tui::bg(if selected.track() == Some(index) {
|
||||
track.color.light.rgb
|
||||
} else {
|
||||
track.color.base.rgb
|
||||
}, Bsp::s(Fill::X(Align::nw(Bsp::e(
|
||||
}, south(w_full(origin_nw(east(
|
||||
format!("·t{index:02} "),
|
||||
Tui::fg(Rgb(255, 255, 255), Tui::bold(true, &track.name))
|
||||
))), ""))) ));}}))))
|
||||
}
|
||||
|
||||
fn view_track_outputs <'a> (&'a self, theme: ItemTheme, _h: u16) -> impl Content<TuiOut> {
|
||||
fn view_track_outputs <'a> (&'a self, theme: ItemTheme, _h: u16) -> impl Draw<Tui> {
|
||||
view_track_row_section(theme,
|
||||
Bsp::s(Fill::X(Align::w(button_2("o", "utput", false))),
|
||||
Thunk::new(|to: &mut TuiOut|for port in self.midi_outs().iter() {
|
||||
to.place(&Fill::X(Align::w(port.port_name())));
|
||||
south(w_full(origin_w(button_2("o", "utput", false))),
|
||||
Thunk::new(|to: &mut Tui|for port in self.midi_outs().iter() {
|
||||
to.place(&w_full(origin_w(port.port_name())));
|
||||
})),
|
||||
button_2("O", "+", false),
|
||||
Tui::bg(theme.darker.rgb, Align::w(Thunk::new(|to: &mut TuiOut|{
|
||||
Tui::bg(theme.darker.rgb, origin_w(Thunk::new(|to: &mut Tui|{
|
||||
for (index, track, _x1, _x2) in self.tracks_with_sizes() {
|
||||
to.place(&Fixed::X(track_width(index, track),
|
||||
Align::nw(Fill::Y(Map::south(1, ||track.sequencer.midi_outs.iter(),
|
||||
to.place(&w_exact(track_width(index, track),
|
||||
origin_nw(h_full(iter_south(1, ||track.sequencer.midi_outs.iter(),
|
||||
|port, index|Tui::fg(Rgb(255, 255, 255),
|
||||
Fixed::Y(1, Tui::bg(track.color.dark.rgb, Fill::X(Align::w(
|
||||
h_exact(1, Tui::bg(track.color.dark.rgb, w_full(origin_w(
|
||||
format!("·o{index:02} {}", port.port_name())))))))))));}}))))
|
||||
}
|
||||
|
||||
fn view_track_inputs <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> {
|
||||
fn view_track_inputs <'a> (&'a self, theme: ItemTheme) -> impl Draw<Tui> {
|
||||
let mut h = 0u16;
|
||||
for track in self.tracks().iter() {
|
||||
h = h.max(track.sequencer.midi_ins.len() as u16);
|
||||
}
|
||||
let content = Thunk::new(move|to: &mut TuiOut|for (index, track, _x1, _x2) in self.tracks_with_sizes() {
|
||||
to.place(&Fixed::XY(track_width(index, track), h + 1,
|
||||
Align::nw(Bsp::s(
|
||||
let content = Thunk::new(move|to: &mut Tui|for (index, track, _x1, _x2) in self.tracks_with_sizes() {
|
||||
to.place(&wh_exact(track_width(index, track), h + 1,
|
||||
origin_nw(south(
|
||||
Tui::bg(track.color.base.rgb,
|
||||
Fill::X(Align::w(row!(
|
||||
Either::new(track.sequencer.monitoring, Tui::fg(Green, "●mon "), "·mon "),
|
||||
Either::new(track.sequencer.recording, Tui::fg(Red, "●rec "), "·rec "),
|
||||
Either::new(track.sequencer.overdub, Tui::fg(Yellow, "●dub "), "·dub "),
|
||||
w_full(origin_w(east!(
|
||||
either(track.sequencer.monitoring, Tui::fg(Green, "●mon "), "·mon "),
|
||||
either(track.sequencer.recording, Tui::fg(Red, "●rec "), "·rec "),
|
||||
either(track.sequencer.overdub, Tui::fg(Yellow, "●dub "), "·dub "),
|
||||
)))),
|
||||
Map::south(1, ||track.sequencer.midi_ins.iter(),
|
||||
iter_south(1, ||track.sequencer.midi_ins.iter(),
|
||||
|port, index|Tui::fg_bg(Rgb(255, 255, 255), track.color.dark.rgb,
|
||||
Fill::X(Align::w(format!("·i{index:02} {}", port.port_name())))))))));
|
||||
w_full(origin_w(format!("·i{index:02} {}", port.port_name())))))))));
|
||||
});
|
||||
view_track_row_section(theme, button_2("i", "nput", false), button_2("I", "+", false),
|
||||
Tui::bg(theme.darker.rgb, Align::w(content)))
|
||||
Tui::bg(theme.darker.rgb, origin_w(content)))
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -739,13 +739,13 @@ pub trait ScenesView: HasEditor + HasSelection + HasSceneScroll + HasClipsSize +
|
|||
})
|
||||
}
|
||||
|
||||
fn view_scenes_names (&self) -> impl Content<TuiOut> {
|
||||
Fixed::X(20, Thunk::new(|to: &mut TuiOut|for (index, scene, ..) in self.scenes_with_sizes() {
|
||||
fn view_scenes_names (&self) -> impl Draw<Tui> {
|
||||
w_exact(20, Thunk::new(|to: &mut Tui|for (index, scene, ..) in self.scenes_with_sizes() {
|
||||
to.place(&self.view_scene_name(index, scene));
|
||||
}))
|
||||
}
|
||||
|
||||
fn view_scene_name <'a> (&'a self, index: usize, scene: &'a Scene) -> impl Content<TuiOut> + 'a {
|
||||
fn view_scene_name <'a> (&'a self, index: usize, scene: &'a Scene) -> impl Draw<Tui> + 'a {
|
||||
let h = if self.selection().scene() == Some(index) && let Some(_editor) = self.editor() {
|
||||
7
|
||||
} else {
|
||||
|
|
@ -756,13 +756,13 @@ pub trait ScenesView: HasEditor + HasSelection + HasSceneScroll + HasClipsSize +
|
|||
} else {
|
||||
scene.color.base.rgb
|
||||
};
|
||||
let a = Fill::X(Align::w(Bsp::e(format!("·s{index:02} "),
|
||||
let a = w_full(origin_w(east(format!("·s{index:02} "),
|
||||
Tui::fg(Tui::g(255), Tui::bold(true, &scene.name)))));
|
||||
let b = When::new(self.selection().scene() == Some(index) && self.is_editing(),
|
||||
Fill::XY(Align::nw(Bsp::s(
|
||||
let b = when(self.selection().scene() == Some(index) && self.is_editing(),
|
||||
wh_full(origin_nw(south(
|
||||
self.editor().as_ref().map(|e|e.clip_status()),
|
||||
self.editor().as_ref().map(|e|e.edit_status())))));
|
||||
Fixed::XY(20, h, Tui::bg(bg, Align::nw(Bsp::s(a, b))))
|
||||
wh_exact(20, h, Tui::bg(bg, origin_nw(south(a, b))))
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue