Compare commits

..

No commits in common. "02312e32a57286af51e1dd155c4d1b8e995b12a4" and "0192d85a19b1705e41a26a280c5fe15c21c63f81" have entirely different histories.

4 changed files with 173 additions and 203 deletions

View file

@ -158,9 +158,6 @@ impl App {
#[tengri_proc::expose] #[tengri_proc::expose]
impl App { impl App {
fn _todo_bool_stub (&self) -> bool {
todo!()
}
fn _todo_isize_stub (&self) -> isize { fn _todo_isize_stub (&self) -> isize {
todo!() todo!()
} }

View file

@ -2,49 +2,49 @@ use crate::*;
pub(crate) use std::fmt::Write; pub(crate) use std::fmt::Write;
pub(crate) use ::tengri::tui::ratatui::prelude::Position; pub(crate) use ::tengri::tui::ratatui::prelude::Position;
// Thunks can be natural error boundaries! impl App {
struct ErrorBoundary<O: Output, T: Content<O>>(std::marker::PhantomData<O>, Perhaps<T>); pub fn view (&self) -> impl Content<TuiOut> + '_ {
impl<T: Content<TuiOut>> Content<TuiOut> for ErrorBoundary<TuiOut, T> { let view: Perhaps<Box<dyn Render<TuiOut>>> =
fn content (&self) -> impl Render<TuiOut> + '_ { Namespace::take_from(self, &mut self.config.view.clone());
ThunkRender::new(|to|match self.1.as_ref() { Either(view.is_ok(),
Ok(Some(content)) => content.render(to), ThunkRender::new(move|to|if let Some(view) = view.as_ref().unwrap().as_ref() {
Ok(None) => to.blit(&"empty?", 0, 0, Some(Style::default().yellow())), Content::render(view, to)
Err(e) => Content::render(&Tui::fg_bg( }),
Rgb(255,224,244), "error?!")
Rgb(96,24,24), //Fill::xy(self.size.of(col! {
Bsp::s( //Tui::bg(Rgb(72,72,0), When(matches!(&view, Err(_)), Bsp::s(
Bsp::e(Tui::bold(true, "oops. "), "rendering failed."), //Fixed::y(1, "view error"),
Bsp::e("\"why?\" ", Tui::bold(true, &format!("{e}"))), //Bsp::s(
)), to) //view.as_ref().err().map(|e|format!("{e}")),
}) //format!("{}", &self.config.view.0.0))))),
//When(matches!(&view, Ok(None)), Bsp::s(
//Tui::bg(Rgb(96,48,0),
//Fixed::y(1, Fill::x(Align::w("no view returned, as defined by:")))),
//Tui::bg(Rgb(72,32,0),
//Fill::x(Stack::south(|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
//for line in self.config.view.0.0.split('\n') {
//add(&Fill::x(Align::w(line)));
//}
//}))))),
//When(matches!(&view, Ok(Some(_))), &view.unwrap().unwrap()),
//}))
} }
} }
#[tengri_proc::view(TuiOut)] #[tengri_proc::view(TuiOut)]
impl App { impl App {
pub fn view (app: &Self) -> impl Content<TuiOut> { pub fn view_nil (&self) -> impl Content<TuiOut> + use<'_> {
ErrorBoundary::<TuiOut, Box<dyn Render<TuiOut> + '_>>(
Default::default(),
Namespace::take_from(app, &mut app.config.view.clone())
)
}
pub fn view_nil (app: &Self) -> impl Content<TuiOut> {
"nil" "nil"
} }
pub fn view_history (app: &Self) -> impl Content<TuiOut> { pub fn view_history (&self) -> impl Content<TuiOut> {
Fixed::y(1, Fill::x(Align::w(FieldH(app.color, Fixed::y(1, Fill::x(Align::w(FieldH(self.color,
format!("History ({})", app.history.len()), format!("History ({})", self.history.len()),
app.history.last().map(|last|Fill::x(Align::w(format!("{:?}", last.0)))))))) self.history.last().map(|last|Fill::x(Align::w(format!("{:?}", last.0))))))))
} }
pub fn view_status_h2 (app: &Self) -> impl Content<TuiOut> { pub fn view_status_h2 (&self) -> impl Content<TuiOut> + use<'_> {
app.update_clock(); self.update_clock();
let theme = app.color; let theme = self.color;
let clock = app.clock(); let playing = self.clock().is_rolling();
let playing = clock.is_rolling();
let cache = clock.view_cache.clone();
//let selection = app.selection().describe(app.tracks(), app.scenes());
let hist_len = app.history.len();
let hist_last = app.history.last();
Fixed::y(2, Stack::east(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{ Fixed::y(2, Stack::east(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
add(&Fixed::x(5, Tui::bg(if playing { Rgb(0, 128, 0) } else { Rgb(128, 64, 0) }, add(&Fixed::x(5, Tui::bg(if playing { Rgb(0, 128, 0) } else { Rgb(128, 64, 0) },
Either::new(false, // TODO Either::new(false, // TODO
@ -60,7 +60,7 @@ impl App {
))); )));
add(&" "); add(&" ");
{ {
let cache = cache.read().unwrap(); let cache = self.project.clock.view_cache.read().unwrap();
add(&Fixed::x(15, Align::w(Bsp::s( add(&Fixed::x(15, Align::w(Bsp::s(
FieldH(theme, "Beat", cache.beat.view.clone()), FieldH(theme, "Beat", cache.beat.view.clone()),
FieldH(theme, "Time", cache.time.view.clone()), FieldH(theme, "Time", cache.time.view.clone()),
@ -73,143 +73,145 @@ impl App {
Fill::x(Align::w(FieldH(theme, "Buf", cache.buf.view.clone()))), Fill::x(Align::w(FieldH(theme, "Buf", cache.buf.view.clone()))),
Fill::x(Align::w(FieldH(theme, "Lat", cache.lat.view.clone()))), Fill::x(Align::w(FieldH(theme, "Lat", cache.lat.view.clone()))),
)))); ))));
//add(&Bsp::s( add(&Bsp::s(
////Fill::x(Align::w(FieldH(theme, "Selected", Align::w(selection)))), Fill::x(Align::w(FieldH(theme, "Selected", Align::w(self.selection().describe(
//Fill::x(Align::w(FieldH(theme, format!("History ({})", hist_len), self.tracks(),
//hist_last.map(|last|Fill::x(Align::w(format!("{:?}", last.0))))))), self.scenes()
//"" ))))),
//)); Fill::x(Align::w(FieldH(theme, format!("History ({})", self.history.len()),
////if let Some(last) = app.history.last() { self.history.last().map(|last|Fill::x(Align::w(format!("{:?}", last.0)))))))
////add(&FieldV(theme, format!("History ({})", app.history.len()), ));
////Fill::x(Align::w(format!("{:?}", last.0))))); //if let Some(last) = self.history.last() {
////} //add(&FieldV(theme, format!("History ({})", self.history.len()),
//Fill::x(Align::w(format!("{:?}", last.0)))));
//}
} }
})) }))
} }
//pub fn view_status_v (&self) -> impl Content<TuiOut> + use<'_> { pub fn view_status_v (&self) -> impl Content<TuiOut> + use<'_> {
//self.update_clock(); self.update_clock();
//let cache = self.project.clock.view_cache.read().unwrap(); let cache = self.project.clock.view_cache.read().unwrap();
//let theme = self.color; let theme = self.color;
//let playing = self.clock().is_rolling(); let playing = self.clock().is_rolling();
//Tui::bg(theme.darker.rgb, Fixed::xy(20, 5, Outer(true, Style::default().fg(Tui::g(96))).enclose( Tui::bg(theme.darker.rgb, Fixed::xy(20, 5, Outer(true, Style::default().fg(Tui::g(96))).enclose(
//col!( col!(
//Fill::x(Align::w(Bsp::e( Fill::x(Align::w(Bsp::e(
//Align::w(Tui::bg(if playing { Rgb(0, 128, 0) } else { Rgb(128, 64, 0) }, Align::w(Tui::bg(if playing { Rgb(0, 128, 0) } else { Rgb(128, 64, 0) },
//Either::new(false, // TODO Either::new(false, // TODO
//Thunk::new(move||Fixed::x(9, Either::new(playing, Thunk::new(move||Fixed::x(9, Either::new(playing,
//Tui::fg(Rgb(0, 255, 0), " PLAYING "), Tui::fg(Rgb(0, 255, 0), " PLAYING "),
//Tui::fg(Rgb(255, 128, 0), " STOPPED "))) Tui::fg(Rgb(255, 128, 0), " STOPPED ")))
//), ),
//Thunk::new(move||Fixed::x(5, Either::new(playing, Thunk::new(move||Fixed::x(5, Either::new(playing,
//Tui::fg(Rgb(0, 255, 0), Bsp::s(" 🭍🭑🬽 ", " 🭞🭜🭘 ",)), Tui::fg(Rgb(0, 255, 0), Bsp::s(" 🭍🭑🬽 ", " 🭞🭜🭘 ",)),
//Tui::fg(Rgb(255, 128, 0), Bsp::s(" ▗▄▖ ", " ▝▀▘ ",)))) Tui::fg(Rgb(255, 128, 0), Bsp::s(" ▗▄▖ ", " ▝▀▘ ",))))
//) )
//) )
//)), )),
//Bsp::s( Bsp::s(
//FieldH(theme, "Beat", cache.beat.view.clone()), FieldH(theme, "Beat", cache.beat.view.clone()),
//FieldH(theme, "Time", cache.time.view.clone()), FieldH(theme, "Time", cache.time.view.clone()),
//), ),
//))), ))),
//Fill::x(Align::w(FieldH(theme, "BPM", cache.bpm.view.clone()))), Fill::x(Align::w(FieldH(theme, "BPM", cache.bpm.view.clone()))),
//Fill::x(Align::w(FieldH(theme, "SR ", cache.sr.view.clone()))), Fill::x(Align::w(FieldH(theme, "SR ", cache.sr.view.clone()))),
//Fill::x(Align::w(FieldH(theme, "Buf", Bsp::e(cache.buf.view.clone(), Bsp::e(" = ", cache.lat.view.clone()))))), Fill::x(Align::w(FieldH(theme, "Buf", Bsp::e(cache.buf.view.clone(), Bsp::e(" = ", cache.lat.view.clone()))))),
//)))) ))))
//} }
//pub fn view_status (&self) -> impl Content<TuiOut> + use<'_> { pub fn view_status (&self) -> impl Content<TuiOut> + use<'_> {
//self.update_clock(); self.update_clock();
//let cache = self.project.clock.view_cache.read().unwrap(); let cache = self.project.clock.view_cache.read().unwrap();
//view_status(Some(self.project.selection.describe(self.tracks(), self.scenes())), view_status(Some(self.project.selection.describe(self.tracks(), self.scenes())),
//cache.sr.view.clone(), cache.buf.view.clone(), cache.lat.view.clone()) cache.sr.view.clone(), cache.buf.view.clone(), cache.lat.view.clone())
//} }
//pub fn view_transport (&self) -> impl Content<TuiOut> + use<'_> { pub fn view_transport (&self) -> impl Content<TuiOut> + use<'_> {
//self.update_clock(); self.update_clock();
//let cache = self.project.clock.view_cache.read().unwrap(); let cache = self.project.clock.view_cache.read().unwrap();
//view_transport(self.project.clock.is_rolling(), view_transport(self.project.clock.is_rolling(),
//cache.bpm.view.clone(), cache.beat.view.clone(), cache.time.view.clone()) cache.bpm.view.clone(), cache.beat.view.clone(), cache.time.view.clone())
//} }
//pub fn view_editor (&self) -> impl Content<TuiOut> + use<'_> { pub fn view_editor (&self) -> impl Content<TuiOut> + use<'_> {
//let bg = self.editor() let bg = self.editor()
//.and_then(|editor|editor.clip().clone()) .and_then(|editor|editor.clip().clone())
//.map(|clip|clip.read().unwrap().color.darker) .map(|clip|clip.read().unwrap().color.darker)
//.unwrap_or(self.color.darker); .unwrap_or(self.color.darker);
//Fill::xy(Tui::bg(bg.rgb, self.editor())) Fill::xy(Tui::bg(bg.rgb, self.editor()))
//} }
//pub fn view_editor_status (&self) -> impl Content<TuiOut> + use<'_> { pub fn view_editor_status (&self) -> impl Content<TuiOut> + use<'_> {
//self.editor().map(|e|Fixed::x(20, Outer(true, Style::default().fg(Tui::g(96))).enclose( self.editor().map(|e|Fixed::x(20, Outer(true, Style::default().fg(Tui::g(96))).enclose(
//Fill::y(Align::n(Bsp::s(e.clip_status(), e.edit_status())))))) Fill::y(Align::n(Bsp::s(e.clip_status(), e.edit_status()))))))
//} }
//pub fn view_midi_ins_status (&self) -> impl Content<TuiOut> + use<'_> { pub fn view_midi_ins_status (&self) -> impl Content<TuiOut> + use<'_> {
//self.project.view_midi_ins_status(self.color) self.project.view_midi_ins_status(self.color)
//} }
//pub fn view_midi_outs_status (&self) -> impl Content<TuiOut> + use<'_> { pub fn view_midi_outs_status (&self) -> impl Content<TuiOut> + use<'_> {
//self.project.view_midi_outs_status(self.color) self.project.view_midi_outs_status(self.color)
//} }
//pub fn view_audio_ins_status (&self) -> impl Content<TuiOut> + use<'_> { pub fn view_audio_ins_status (&self) -> impl Content<TuiOut> + use<'_> {
//self.project.view_audio_ins_status(self.color) self.project.view_audio_ins_status(self.color)
//} }
//pub fn view_audio_outs_status (&self) -> impl Content<TuiOut> + use<'_> { pub fn view_audio_outs_status (&self) -> impl Content<TuiOut> + use<'_> {
//self.project.view_audio_outs_status(self.color) self.project.view_audio_outs_status(self.color)
//} }
//pub fn view_scenes (&self) -> impl Content<TuiOut> + use<'_> { pub fn view_scenes (&self) -> impl Content<TuiOut> + use<'_> {
//Bsp::e( Bsp::e(
//Fixed::x(20, Align::nw(self.project.view_scenes_names())), Fixed::x(20, Align::nw(self.project.view_scenes_names())),
//self.project.view_scenes_clips(), self.project.view_scenes_clips(),
//) )
//} }
//pub fn view_scenes_names (&self) -> impl Content<TuiOut> + use<'_> { pub fn view_scenes_names (&self) -> impl Content<TuiOut> + use<'_> {
//self.project.view_scenes_names() self.project.view_scenes_names()
//} }
//pub fn view_scenes_clips (&self) -> impl Content<TuiOut> + use<'_> { pub fn view_scenes_clips (&self) -> impl Content<TuiOut> + use<'_> {
//self.project.view_scenes_clips() self.project.view_scenes_clips()
//} }
//pub fn view_tracks_inputs <'a> (&'a self) -> impl Content<TuiOut> + use<'a> { pub fn view_tracks_inputs <'a> (&'a self) -> impl Content<TuiOut> + use<'a> {
//Fixed::y(1 + self.project.midi_ins.len() as u16, Fixed::y(1 + self.project.midi_ins.len() as u16,
//self.project.view_inputs(self.color)) self.project.view_inputs(self.color))
//} }
//pub fn view_tracks_outputs <'a> (&'a self) -> impl Content<TuiOut> + use<'a> { pub fn view_tracks_outputs <'a> (&'a self) -> impl Content<TuiOut> + use<'a> {
//self.project.view_outputs(self.color) self.project.view_outputs(self.color)
//} }
//pub fn view_tracks_devices <'a> (&'a self) -> impl Content<TuiOut> + use<'a> { pub fn view_tracks_devices <'a> (&'a self) -> impl Content<TuiOut> + use<'a> {
//Fixed::y(4, self.project.view_track_devices(self.color)) Fixed::y(4, self.project.view_track_devices(self.color))
//} }
//pub fn view_tracks_names <'a> (&'a self) -> impl Content<TuiOut> + use<'a> { pub fn view_tracks_names <'a> (&'a self) -> impl Content<TuiOut> + use<'a> {
//Fixed::y(2, self.project.view_track_names(self.color)) Fixed::y(2, self.project.view_track_names(self.color))
//} }
//pub fn view_pool (&self) -> impl Content<TuiOut> + use<'_> { pub fn view_pool (&self) -> impl Content<TuiOut> + use<'_> {
//Fixed::x(20, Bsp::s( Fixed::x(20, Bsp::s(
//Fill::x(Align::w(FieldH(self.color, "Clip pool:", ""))), Fill::x(Align::w(FieldH(self.color, "Clip pool:", ""))),
//Fill::y(Align::n(Tui::bg(Rgb(0, 0, 0), Outer(true, Style::default().fg(Tui::g(96))) Fill::y(Align::n(Tui::bg(Rgb(0, 0, 0), Outer(true, Style::default().fg(Tui::g(96)))
//.enclose(PoolView(&self.pool))))))) .enclose(PoolView(&self.pool)))))))
//} }
//pub fn view_samples_keys (&self) -> impl Content<TuiOut> + use<'_> { pub fn view_samples_keys (&self) -> impl Content<TuiOut> + use<'_> {
//self.project.sampler().map(|s|s.view_list(true, self.editor().unwrap())) self.project.sampler().map(|s|s.view_list(true, self.editor().unwrap()))
//} }
//pub fn view_samples_grid (&self) -> impl Content<TuiOut> + use<'_> { pub fn view_samples_grid (&self) -> impl Content<TuiOut> + use<'_> {
//self.project.sampler().map(|s|s.view_grid()) self.project.sampler().map(|s|s.view_grid())
//} }
//pub fn view_sample_viewer (&self) -> impl Content<TuiOut> + use<'_> { pub fn view_sample_viewer (&self) -> impl Content<TuiOut> + use<'_> {
//self.project.sampler().map(|s|s.view_sample(self.editor().unwrap().get_note_pos())) self.project.sampler().map(|s|s.view_sample(self.editor().unwrap().get_note_pos()))
//} }
//pub fn view_sample_info (&self) -> impl Content<TuiOut> + use<'_> { pub fn view_sample_info (&self) -> impl Content<TuiOut> + use<'_> {
//self.project.sampler().map(|s|s.view_sample_info(self.editor().unwrap().get_note_pos())) self.project.sampler().map(|s|s.view_sample_info(self.editor().unwrap().get_note_pos()))
//} }
//pub fn view_sample_status (&self) -> impl Content<TuiOut> + use<'_> { pub fn view_sample_status (&self) -> impl Content<TuiOut> + use<'_> {
//self.project.sampler().map(|s|Outer(true, Style::default().fg(Tui::g(96))).enclose( self.project.sampler().map(|s|Outer(true, Style::default().fg(Tui::g(96))).enclose(
//Fill::y(Align::n(s.view_sample_status(self.editor().unwrap().get_note_pos()))))) Fill::y(Align::n(s.view_sample_status(self.editor().unwrap().get_note_pos())))))
//} }
//pub fn view_meters_input (&self) -> impl Content<TuiOut> + use<'_> { pub fn view_meters_input (&self) -> impl Content<TuiOut> + use<'_> {
//self.project.sampler().map(|s|s.view_meters_input()) self.project.sampler().map(|s|s.view_meters_input())
//} }
//pub fn view_meters_output (&self) -> impl Content<TuiOut> + use<'_> { pub fn view_meters_output (&self) -> impl Content<TuiOut> + use<'_> {
//self.project.sampler().map(|s|s.view_meters_output()) self.project.sampler().map(|s|s.view_meters_output())
//} }
//pub fn view_dialog (&self) -> impl Content<TuiOut> + use<'_> { pub fn view_dialog (&self) -> impl Content<TuiOut> + use<'_> {
//self.dialog.as_ref().map(|dialog|Bsp::b("", self.dialog.as_ref().map(|dialog|Bsp::b("",
//Fixed::xy(70, 23, Tui::fg_bg(Rgb(255,255,255), Rgb(16,16,16), Bsp::b( Fixed::xy(70, 23, Tui::fg_bg(Rgb(255,255,255), Rgb(16,16,16), Bsp::b(
//Repeat(" "), Outer(true, Style::default().fg(Tui::g(96))) Repeat(" "), Outer(true, Style::default().fg(Tui::g(96)))
//.enclose(dialog)))))) .enclose(dialog))))))
//} }
} }
impl ScenesView for App { impl ScenesView for App {

View file

@ -132,33 +132,4 @@ impl ViewCache {
cache.bpm.update(None, rewrite!(buf, "{}", ViewCache::BPM_EMPTY)); cache.bpm.update(None, rewrite!(buf, "{}", ViewCache::BPM_EMPTY));
} }
} }
//pub fn view_h2 (&self) -> impl Content<TuiOut> {
//let cache = self.project.clock.view_cache.clone();
//let cache = cache.read().unwrap();
//add(&Fixed::x(15, Align::w(Bsp::s(
//FieldH(theme, "Beat", cache.beat.view.clone()),
//FieldH(theme, "Time", cache.time.view.clone()),
//))));
//add(&Fixed::x(13, Align::w(Bsp::s(
//Fill::x(Align::w(FieldH(theme, "BPM", cache.bpm.view.clone()))),
//Fill::x(Align::w(FieldH(theme, "SR ", cache.sr.view.clone()))),
//))));
//add(&Fixed::x(12, Align::w(Bsp::s(
//Fill::x(Align::w(FieldH(theme, "Buf", cache.buf.view.clone()))),
//Fill::x(Align::w(FieldH(theme, "Lat", cache.lat.view.clone()))),
//))));
//add(&Bsp::s(
//Fill::x(Align::w(FieldH(theme, "Selected", Align::w(self.selection().describe(
//self.tracks(),
//self.scenes()
//))))),
//Fill::x(Align::w(FieldH(theme, format!("History ({})", self.history.len()),
//self.history.last().map(|last|Fill::x(Align::w(format!("{:?}", last.0)))))))
//));
////if let Some(last) = self.history.last() {
////add(&FieldV(theme, format!("History ({})", self.history.len()),
////Fill::x(Align::w(format!("{:?}", last.0)))));
////}
//}
} }

2
deps/tengri vendored

@ -1 +1 @@
Subproject commit a4a1066f187e6b2e119e3c3b471219f1e128d4af Subproject commit 2048dd2263fc4389c8f510bfd12c851efe34026f