mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
This commit is contained in:
parent
0d7998a5a8
commit
fa5f67f010
8 changed files with 714 additions and 688 deletions
|
|
@ -46,7 +46,7 @@ pub struct App {
|
|||
/// Available view modes and input bindings
|
||||
pub config: Config,
|
||||
/// Currently selected mode
|
||||
pub mode: Mode<Arc<str>>,
|
||||
pub mode: Arc<Mode<Arc<str>>>,
|
||||
/// Contains the currently edited musical arrangement
|
||||
pub project: Arrangement,
|
||||
/// Contains all recently created clips.
|
||||
|
|
@ -168,7 +168,9 @@ impl Config {
|
|||
match key {
|
||||
"name" => mode.name.push(item.expr()?.tail()?.map(|x|x.trim()).unwrap_or("").into()),
|
||||
"info" => mode.info.push(item.expr()?.tail()?.map(|x|x.trim()).unwrap_or("").into()),
|
||||
"keys" => mode.keys.push(item.expr()?.tail()?.map(|x|x.trim()).unwrap_or("").into()),
|
||||
"keys" => {
|
||||
item.expr()?.tail()?.each(|item|{mode.keys.push(item.trim().into()); Ok(())})?;
|
||||
},
|
||||
"mode" => if let Some(id) = item.expr()?.tail()?.head()? {
|
||||
let mut submode = Mode::default();
|
||||
Self::load_mode_one(&mut submode, item.expr()?.tail()?.tail()?)?;
|
||||
|
|
@ -245,27 +247,17 @@ fn render_dsl <'t> (
|
|||
Tui::fg(bg, Fixed::y(1, Fill::x(RepeatH("▀")))),
|
||||
})
|
||||
}
|
||||
|
||||
fn wrap_dialog (dialog: impl Content<TuiOut>) -> impl Content<TuiOut> {
|
||||
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))).enclose(dialog))))
|
||||
}
|
||||
impl ScenesView for App {
|
||||
fn h_scenes (&self) -> u16 {
|
||||
(self.height() as u16).saturating_sub(20)
|
||||
}
|
||||
fn w_side (&self) -> u16 {
|
||||
20
|
||||
}
|
||||
fn w_mid (&self) -> u16 {
|
||||
(self.width() as u16).saturating_sub(self.w_side())
|
||||
}
|
||||
}
|
||||
handle!(TuiIn:|self: App, input|{
|
||||
for id in self.mode.keys.iter() {
|
||||
if let Some(event_map) = self.config.binds.read().unwrap().get(id.as_ref()) {
|
||||
if let Some(bindings) = event_map.query(input.event()) {
|
||||
for binding in bindings {
|
||||
for command in binding.commands.iter() {
|
||||
let command: Option<AppCommand> = self.from(command)?;
|
||||
if let Some(command) = command {
|
||||
panic!("{command:?}");
|
||||
}
|
||||
}
|
||||
panic!("{binding:?}");
|
||||
}
|
||||
}
|
||||
|
|
@ -391,142 +383,6 @@ impl App {
|
|||
}
|
||||
}
|
||||
|
||||
macro_rules!dsl_words((|$state:ident|$({
|
||||
$($word:literal => $body:expr),* $(,)?
|
||||
})?)=>{
|
||||
const WORDS: DslNsMap<'t, fn (&'t Self)->Perhaps<Box<dyn Render<TuiOut>>>> = DslNsMap::new(&[$(
|
||||
$(($word, |$state: &Self|{Ok(Some($body))})),*
|
||||
)? ]);
|
||||
});
|
||||
macro_rules!dsl_exprs((|$state:ident|$({
|
||||
$($name:literal ($($arg:ident:$ty:ty),* $(,)?) => $body:expr),* $(,)?
|
||||
})?)=>{
|
||||
const EXPRS: DslNsMap<'t, fn (&'t Self, &str)->Perhaps<Box<dyn Render<TuiOut>>>> = DslNsMap::new(&[$(
|
||||
$(($name, |$state: &Self, tail: &str|{
|
||||
$(
|
||||
let head = tail.head()?.unwrap_or_default();
|
||||
let tail = tail.tail()?.unwrap_or_default();
|
||||
let $arg: $ty = if let Some(arg) = $state.from(&head)? {
|
||||
arg
|
||||
} else {
|
||||
return Err(format!("{}: arg \"{}\" ({}) got: {head}, remaining: {tail}",
|
||||
$name,
|
||||
stringify!($arg),
|
||||
stringify!($ty),
|
||||
).into())
|
||||
};
|
||||
)*
|
||||
Ok(Some($body))
|
||||
})),*
|
||||
)? ]);
|
||||
});
|
||||
|
||||
impl<'t> DslNs<'t, Box<dyn Render<TuiOut>>> for App {
|
||||
dsl_exprs!(|app|{
|
||||
"fg" (color: Color, x: Box<dyn Render<TuiOut>>) => Box::new(Tui::fg(color, x)),
|
||||
"bg" (color: Color, x: Box<dyn Render<TuiOut>>) => Box::new(Tui::bg(color, x)),
|
||||
"fg/bg" (fg: Color, bg: Color, x: Box<dyn Render<TuiOut>>) => Box::new(Tui::fg_bg(fg, bg, x)),
|
||||
|
||||
"bsp/n" (a: Box<dyn Render<TuiOut>>, b: Box<dyn Render<TuiOut>>) => Box::new(Bsp::n(a, b)),
|
||||
"bsp/s" (a: Box<dyn Render<TuiOut>>, b: Box<dyn Render<TuiOut>>) => Box::new(Bsp::s(a, b)),
|
||||
"bsp/e" (a: Box<dyn Render<TuiOut>>, b: Box<dyn Render<TuiOut>>) => Box::new(Bsp::e(a, b)),
|
||||
"bsp/w" (a: Box<dyn Render<TuiOut>>, b: Box<dyn Render<TuiOut>>) => Box::new(Bsp::w(a, b)),
|
||||
"bsp/a" (a: Box<dyn Render<TuiOut>>, b: Box<dyn Render<TuiOut>>) => Box::new(Bsp::a(a, b)),
|
||||
"bsp/b" (a: Box<dyn Render<TuiOut>>, b: Box<dyn Render<TuiOut>>) => Box::new(Bsp::b(a, b)),
|
||||
|
||||
"align/n" (x: Box<dyn Render<TuiOut>>) => Box::new(Align::n(x)),
|
||||
"align/s" (x: Box<dyn Render<TuiOut>>) => Box::new(Align::s(x)),
|
||||
"align/e" (x: Box<dyn Render<TuiOut>>) => Box::new(Align::e(x)),
|
||||
"align/w" (x: Box<dyn Render<TuiOut>>) => Box::new(Align::w(x)),
|
||||
"align/x" (x: Box<dyn Render<TuiOut>>) => Box::new(Align::x(x)),
|
||||
"align/y" (x: Box<dyn Render<TuiOut>>) => Box::new(Align::y(x)),
|
||||
"align/c" (x: Box<dyn Render<TuiOut>>) => Box::new(Align::c(x)),
|
||||
|
||||
"fill/x" (x: Box<dyn Render<TuiOut>>) => Box::new(Fill::x(x)),
|
||||
"fill/y" (x: Box<dyn Render<TuiOut>>) => Box::new(Fill::y(x)),
|
||||
"fill/xy" (x: Box<dyn Render<TuiOut>>) => Box::new(Fill::xy(x)),
|
||||
|
||||
"fixed/x" (x: u16, c: Box<dyn Render<TuiOut>>) => Box::new(Fixed::x(x, c)),
|
||||
"fixed/y" (y: u16, c: Box<dyn Render<TuiOut>>) => Box::new(Fixed::y(y, c)),
|
||||
"fixed/xy" (x: u16, y: u16, c: Box<dyn Render<TuiOut>>) => Box::new(Fixed::xy(x, y, c)),
|
||||
|
||||
"min/x" (x: u16, c: Box<dyn Render<TuiOut>>) => Box::new(Min::x(x, c)),
|
||||
"min/y" (y: u16, c: Box<dyn Render<TuiOut>>) => Box::new(Min::y(y, c)),
|
||||
"min/xy" (x: u16, y: u16, c: Box<dyn Render<TuiOut>>) => Box::new(Min::xy(x, y, c)),
|
||||
|
||||
"max/x" (x: u16, c: Box<dyn Render<TuiOut>>) => Box::new(Max::x(x, c)),
|
||||
"max/y" (y: u16, c: Box<dyn Render<TuiOut>>) => Box::new(Max::y(y, c)),
|
||||
"max/xy" (x: u16, y: u16, c: Box<dyn Render<TuiOut>>) => Box::new(Max::xy(x, y, c)),
|
||||
});
|
||||
/// Resolve an expression if known.
|
||||
fn from_expr <D: Dsl> (&'t self, dsl: D) -> Perhaps<Box<dyn Render<TuiOut>>> {
|
||||
if let Some(head) = dsl.expr().head()? {
|
||||
for (key, value) in Self::EXPRS.0.iter() {
|
||||
if head == *key {
|
||||
return value(self, dsl.expr().tail()?.unwrap_or(""))
|
||||
}
|
||||
}
|
||||
}
|
||||
return Ok(None)
|
||||
}
|
||||
dsl_words!(|app|{
|
||||
":templates" => Box::new({
|
||||
let modes = app.config.modes.clone();
|
||||
let height = (modes.read().unwrap().len() * 2) as u16;
|
||||
Min::x(30, Fixed::y(height, Stack::south(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
|
||||
for (index, (id, profile)) in modes.read().unwrap().iter().enumerate() {
|
||||
let bg = if index == 0 { Rgb(48,64,32) } else { Rgb(16, 32, 24) };
|
||||
let name = profile.name.get(0).map(|x|x.as_ref()).unwrap_or("<no name>");
|
||||
let info = profile.info.get(0).map(|x|x.as_ref()).unwrap_or("<no info>");
|
||||
let fg1 = Rgb(224, 192, 128);
|
||||
let fg2 = Rgb(224, 128, 32);
|
||||
add(&Fixed::y(2, Fill::x(Tui::bg(bg, Bsp::s(
|
||||
Bsp::a(Fill::x(Align::w(Tui::fg(fg1, name))),
|
||||
Fill::x(Align::e(Tui::fg(fg2, id)))),
|
||||
Align::w(info))))));
|
||||
}})))}),
|
||||
":sessions" => Box::new(Min::x(30, Fixed::y(6, Stack::south(
|
||||
move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
|
||||
let fg = Rgb(224, 192, 128);
|
||||
for (index, name) in ["session1", "session2", "session3"].iter().enumerate() {
|
||||
let bg = if index == 0 { Rgb(48,64,32) } else { Rgb(16, 32, 24) };
|
||||
add(&Fixed::y(2, Fill::x(Tui::bg(bg, Align::w(Tui::fg(fg, name))))));
|
||||
}
|
||||
}
|
||||
)))),
|
||||
":browse/title" => Box::new(Fill::x(Align::w(FieldV(Default::default(),
|
||||
match app.dialog.browser_target().unwrap() {
|
||||
BrowserTarget::SaveProject => "Save project:",
|
||||
BrowserTarget::LoadProject => "Load project:",
|
||||
BrowserTarget::ImportSample(_) => "Import sample:",
|
||||
BrowserTarget::ExportSample(_) => "Export sample:",
|
||||
BrowserTarget::ImportClip(_) => "Import clip:",
|
||||
BrowserTarget::ExportClip(_) => "Export clip:",
|
||||
}, Shrink::x(3, Fixed::y(1, Tui::fg(Tui::g(96), RepeatH("🭻")))))))),
|
||||
":device" => {
|
||||
let selected = app.dialog.device_kind().unwrap();
|
||||
Box::new(Bsp::s(Tui::bold(true, "Add device"), Map::south(1,
|
||||
move||device_kinds().iter(),
|
||||
move|label: &&'static str, i|{
|
||||
let bg = if i == selected { Rgb(64,128,32) } else { Rgb(0,0,0) };
|
||||
let lb = if i == selected { "[ " } else { " " };
|
||||
let rb = if i == selected { " ]" } else { " " };
|
||||
Fill::x(Tui::bg(bg, Bsp::e(lb, Bsp::w(rb, "FIXME device name")))) }))) },
|
||||
});
|
||||
/// Resolve a symbol if known.
|
||||
fn from_word <D: Dsl> (&'t self, dsl: D) -> Perhaps<Box<dyn Render<TuiOut>>> {
|
||||
if let Some(dsl) = dsl.word()? {
|
||||
let views = self.config.views.read().unwrap();
|
||||
if let Some(view) = views.get(dsl) {
|
||||
let view = view.clone();
|
||||
std::mem::drop(views);
|
||||
return Ok(Some(render_dsl(self, view.as_ref())))
|
||||
}
|
||||
for (word, get) in Self::WORDS.0 { if dsl == *word { return get(self) } }
|
||||
}
|
||||
return Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
dsl_ns! { |app: App|
|
||||
|
||||
|
|
@ -604,32 +460,6 @@ dsl_ns! { |app: App|
|
|||
}
|
||||
};
|
||||
|
||||
AppCommand => {
|
||||
("stop-all") => todo!(),//app.project.stop_all(),
|
||||
("enqueue", clip: Option<Arc<RwLock<MidiClip>>>) => todo!(),
|
||||
("history", delta: isize) => todo!(),
|
||||
("zoom", zoom: usize) => todo!(),
|
||||
("select", selection: Selection) => todo!(),
|
||||
("dialog" / command: DialogCommand) => todo!(),
|
||||
("project" / command: ArrangementCommand) => todo!(),
|
||||
("clock" / command: ClockCommand) => todo!(),
|
||||
("sampler" / command: SamplerCommand) => todo!(),
|
||||
("pool" / command: PoolCommand) => todo!(),
|
||||
("pool" / editor: MidiEditCommand) => todo!(),
|
||||
};
|
||||
|
||||
DialogCommand;
|
||||
|
||||
ArrangementCommand;
|
||||
|
||||
ClockCommand;
|
||||
|
||||
SamplerCommand;
|
||||
|
||||
PoolCommand;
|
||||
|
||||
MidiEditCommand;
|
||||
|
||||
Color => {
|
||||
("g", n: u8) => Color::Rgb(n, n, n),
|
||||
("rgb", red: u8, green: u8, blue: u8) => Color::Rgb(red, green, blue),
|
||||
|
|
@ -655,6 +485,49 @@ dsl_ns! { num |app: App|
|
|||
isize;
|
||||
}
|
||||
|
||||
fn wrap_dialog (dialog: impl Content<TuiOut>) -> impl Content<TuiOut> {
|
||||
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))).enclose(dialog))))
|
||||
}
|
||||
impl ScenesView for App {
|
||||
fn w_side (&self) -> u16 { 20 }
|
||||
fn w_mid (&self) -> u16 { (self.width() as u16).saturating_sub(self.w_side()) }
|
||||
fn h_scenes (&self) -> u16 { (self.height() as u16).saturating_sub(20) }
|
||||
}
|
||||
|
||||
macro_rules!dsl_words((|$state:ident|->$Type:ty$({
|
||||
$($word:literal => $body:expr),* $(,)?
|
||||
})?)=>{
|
||||
const WORDS: DslNsMap<'t, fn (&'t Self)->Perhaps<$Type>> = DslNsMap::new(&[$(
|
||||
$(($word, |$state: &Self|{Ok(Some($body))})),*
|
||||
)? ]);
|
||||
});
|
||||
macro_rules!dsl_exprs((|$state:ident|->$Type:ty$({
|
||||
$($name:literal ($($arg:ident:$ty:ty),* $(,)?) => $body:expr),* $(,)?
|
||||
})?)=>{
|
||||
const EXPRS: DslNsMap<'t, fn (&'t Self, &str)->Perhaps<$Type>> = DslNsMap::new(&[$(
|
||||
$(($name, |$state: &Self, tail: &str|{
|
||||
$(
|
||||
let head = tail.head()?.unwrap_or_default();
|
||||
let tail = tail.tail()?.unwrap_or_default();
|
||||
let $arg: $ty = if let Some(arg) = $state.from(&head)? {
|
||||
arg
|
||||
} else {
|
||||
return Err(format!("{}: arg \"{}\" ({}) got: {head}, remaining: {tail}",
|
||||
$name,
|
||||
stringify!($arg),
|
||||
stringify!($ty),
|
||||
).into())
|
||||
};
|
||||
)*
|
||||
Ok(Some($body))
|
||||
})),*
|
||||
)? ]);
|
||||
});
|
||||
|
||||
mod app_view; pub use self::app_view::*;
|
||||
mod app_bind; pub use self::app_bind::*;
|
||||
|
||||
//#[dizzle::ns]
|
||||
//#[dizzle::ns::include(TuiOut)]
|
||||
//trait AppApi {
|
||||
|
|
@ -677,121 +550,6 @@ dsl_ns! { num |app: App|
|
|||
//}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//#[derive(Clone, Debug)]
|
||||
//pub enum DialogCommand {
|
||||
//Open { dialog: Dialog },
|
||||
//Close
|
||||
//}
|
||||
|
||||
//impl Command<Option<Dialog>> for DialogCommand {
|
||||
//fn execute (self, state: &mut Option<Dialog>) -> Perhaps<Self> {
|
||||
//match self {
|
||||
//Self::Open { dialog } => {
|
||||
//*state = Some(dialog);
|
||||
//},
|
||||
//Self::Close => {
|
||||
//*state = None;
|
||||
//}
|
||||
//};
|
||||
//Ok(None)
|
||||
//}
|
||||
//}
|
||||
|
||||
//dsl!(DialogCommand: |self: Dialog, iter|todo!());
|
||||
//Dsl::take(&mut self.dialog, iter));
|
||||
|
||||
//#[tengri_proc::command(Option<Dialog>)]//Nope.
|
||||
//impl DialogCommand {
|
||||
//fn open (dialog: &mut Option<Dialog>, new: Dialog) -> Perhaps<Self> {
|
||||
//*dialog = Some(new);
|
||||
//Ok(None)
|
||||
//}
|
||||
//fn close (dialog: &mut Option<Dialog>) -> Perhaps<Self> {
|
||||
//*dialog = None;
|
||||
//Ok(None)
|
||||
//}
|
||||
//}
|
||||
//
|
||||
//dsl_bind!(AppCommand: App {
|
||||
//enqueue = |app, clip: Option<Arc<RwLock<MidiClip>>>| { todo!() };
|
||||
//history = |app, delta: isize| { todo!() };
|
||||
//zoom = |app, zoom: usize| { todo!() };
|
||||
//stop_all = |app| { app.tracks_stop_all(); Ok(None) };
|
||||
////dialog = |app, command: DialogCommand|
|
||||
////Ok(command.delegate(&mut app.dialog, |c|Self::Dialog{command: c})?);
|
||||
//project = |app, command: ArrangementCommand|
|
||||
//Ok(command.delegate(&mut app.project, |c|Self::Project{command: c})?);
|
||||
//clock = |app, command: ClockCommand|
|
||||
//Ok(command.execute(app.clock_mut())?.map(|c|Self::Clock{command: c}));
|
||||
//sampler = |app, command: SamplerCommand|
|
||||
//Ok(app.project.sampler_mut().map(|s|command.delegate(s, |command|Self::Sampler{command}))
|
||||
//.transpose()?.flatten());
|
||||
//pool = |app, command: PoolCommand| {
|
||||
//let undo = command.clone().delegate(&mut app.pool, |command|AppCommand::Pool{command})?;
|
||||
//// update linked editor after pool action
|
||||
//match command {
|
||||
//// autoselect: automatically load selected clip in editor
|
||||
//PoolCommand::Select { .. } |
|
||||
//// autocolor: update color in all places simultaneously
|
||||
//PoolCommand::Clip { command: PoolClipCommand::SetColor { .. } } => {
|
||||
//let clip = app.pool.clip().clone();
|
||||
//app.editor_mut().map(|editor|editor.set_clip(clip.as_ref()))
|
||||
//},
|
||||
//_ => None
|
||||
//};
|
||||
//Ok(undo)
|
||||
//};
|
||||
//select = |app, selection: Selection| {
|
||||
//*app.project.selection_mut() = selection;
|
||||
////todo!
|
||||
////if let Some(ref mut editor) = app.editor_mut() {
|
||||
////editor.set_clip(match selection {
|
||||
////Selection::TrackClip { track, scene } if let Some(Some(Some(clip))) = app
|
||||
////.project
|
||||
////.scenes.get(scene)
|
||||
////.map(|s|s.clips.get(track))
|
||||
////=>
|
||||
////Some(clip),
|
||||
////_ =>
|
||||
////None
|
||||
////});
|
||||
////}
|
||||
//Ok(None)
|
||||
////("select" [t: usize, s: usize] Some(match (t.expect("no track"), s.expect("no scene")) {
|
||||
////(0, 0) => Self::Select(Selection::Mix),
|
||||
////(t, 0) => Self::Select(Selection::Track(t)),
|
||||
////(0, s) => Self::Select(Selection::Scene(s)),
|
||||
////(t, s) => Self::Select(Selection::TrackClip { track: t, scene: s }) })))
|
||||
//// autoedit: load focused clip in editor.
|
||||
//};
|
||||
////fn color (app: &mut App, theme: ItemTheme) -> Perhaps<Self> {
|
||||
////Ok(app.set_color(Some(theme)).map(|theme|Self::Color{theme}))
|
||||
////}
|
||||
////fn launch (app: &mut App) -> Perhaps<Self> {
|
||||
////app.project.launch();
|
||||
////Ok(None)
|
||||
////}
|
||||
//toggle_editor = |app, value: bool|{ app.toggle_editor(Some(value)); Ok(None) };
|
||||
//editor = |app, command: MidiEditCommand| Ok(if let Some(editor) = app.editor_mut() {
|
||||
//let undo = command.clone().delegate(editor, |command|AppCommand::Editor{command})?;
|
||||
//// update linked sampler after editor action
|
||||
//app.project.sampler_mut().map(|sampler|match command {
|
||||
//// autoselect: automatically select sample in sampler
|
||||
//MidiEditCommand::SetNotePos { pos } => { sampler.set_note_pos(pos); },
|
||||
//_ => {}
|
||||
//});
|
||||
//undo
|
||||
//} else {
|
||||
//None
|
||||
//});
|
||||
//});
|
||||
//take!(ClockCommand |state: App, iter|Take::take(state.clock(), iter));
|
||||
//take!(MidiEditCommand |state: App, iter|Ok(state.editor().map(|x|Take::take(x, iter)).transpose()?.flatten()));
|
||||
//take!(PoolCommand |state: App, iter|Take::take(&state.pool, iter));
|
||||
//take!(SamplerCommand |state: App, iter|Ok(state.project.sampler().map(|x|Take::take(x, iter)).transpose()?.flatten()));
|
||||
//take!(ArrangementCommand |state: App, iter|Take::take(&state.project, iter));
|
||||
//take!(DialogCommand |state: App, iter|Take::take(&state.dialog, iter));
|
||||
//has_editor!(|self: App|{
|
||||
//editor = self.editor;
|
||||
//editor_w = {
|
||||
|
|
@ -804,222 +562,3 @@ dsl_ns! { num |app: App|
|
|||
//editor_h = 15;
|
||||
//is_editing = self.editor.is_some();
|
||||
//});
|
||||
|
||||
//Bsp::s("",
|
||||
//Map::south(1,
|
||||
//move||app.config.binds.layers.iter()
|
||||
//.filter_map(|a|(a.0)(app).then_some(a.1))
|
||||
//.flat_map(|a|a)
|
||||
//.filter_map(|x|if let Value::Exp(_, iter)=x.value{ Some(iter) } else { None })
|
||||
//.skip(offset)
|
||||
//.take(20),
|
||||
//|mut b,i|Fixed::x(60, Align::w(Bsp::e("(", Bsp::e(
|
||||
//b.next().map(|t|Fixed::x(16, Align::w(Tui::fg(Rgb(64,224,0), format!("{}", t.value))))),
|
||||
//Bsp::e(" ", Align::w(format!("{}", b.0.0.trim()))))))))))),
|
||||
|
||||
//Dialog::Browser(BrowserTarget::Load, browser) => {
|
||||
//"bobcat".boxed()
|
||||
////Bsp::s(
|
||||
////Fill::x(Align::w(Margin::xy(1, 1, Bsp::e(
|
||||
////Tui::bold(true, " Load project: "),
|
||||
////Shrink::x(3, Fixed::y(1, RepeatH("🭻"))))))),
|
||||
////Outer(true, Style::default().fg(Tui::g(96)))
|
||||
////.enclose(Fill::xy(browser)))
|
||||
//},
|
||||
//Dialog::Browser(BrowserTarget::Export, browser) => {
|
||||
//"bobcat".boxed()
|
||||
////Bsp::s(
|
||||
////Fill::x(Align::w(Margin::xy(1, 1, Bsp::e(
|
||||
////Tui::bold(true, " Export: "),
|
||||
////Shrink::x(3, Fixed::y(1, RepeatH("🭻"))))))),
|
||||
////Outer(true, Style::default().fg(Tui::g(96)))
|
||||
////.enclose(Fill::xy(browser)))
|
||||
//},
|
||||
//Dialog::Browser(BrowserTarget::Import, browser) => {
|
||||
//"bobcat".boxed()
|
||||
////Bsp::s(
|
||||
////Fill::x(Align::w(Margin::xy(1, 1, Bsp::e(
|
||||
////Tui::bold(true, " Import: "),
|
||||
////Shrink::x(3, Fixed::y(1, RepeatH("🭻"))))))),
|
||||
////Outer(true, Style::default().fg(Tui::g(96)))
|
||||
////.enclose(Fill::xy(browser)))
|
||||
//},
|
||||
//
|
||||
//pub fn view_meters_input (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//self.project.sampler().map(|s|
|
||||
//s.view_meters_input())
|
||||
//}
|
||||
//pub fn view_meters_output (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//self.project.sampler().map(|s|
|
||||
//s.view_meters_output())
|
||||
//}
|
||||
//pub fn view_history (&self) -> impl Content<TuiOut> {
|
||||
//Fixed::y(1, Fill::x(Align::w(FieldH(self.color,
|
||||
//format!("History ({})", self.history.len()),
|
||||
//self.history.last().map(|last|Fill::x(Align::w(format!("{:?}", last.0))))))))
|
||||
//}
|
||||
//pub fn view_status_h2 (&self) -> impl Content<TuiOut> {
|
||||
//self.update_clock();
|
||||
//let theme = self.color;
|
||||
//let clock = self.clock();
|
||||
//let playing = clock.is_rolling();
|
||||
//let cache = clock.view_cache.clone();
|
||||
////let selection = self.selection().describe(self.tracks(), self.scenes());
|
||||
//let hist_len = self.history.len();
|
||||
//let hist_last = self.history.last();
|
||||
//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) },
|
||||
//Either::new(false, // TODO
|
||||
//Thunk::new(move||Fixed::x(9, Either::new(playing,
|
||||
//Tui::fg(Rgb(0, 255, 0), " PLAYING "),
|
||||
//Tui::fg(Rgb(255, 128, 0), " STOPPED ")))
|
||||
//),
|
||||
//Thunk::new(move||Fixed::x(5, Either::new(playing,
|
||||
//Tui::fg(Rgb(0, 255, 0), Bsp::s(" 🭍🭑🬽 ", " 🭞🭜🭘 ",)),
|
||||
//Tui::fg(Rgb(255, 128, 0), Bsp::s(" ▗▄▖ ", " ▝▀▘ ",))))
|
||||
//)
|
||||
//)
|
||||
//)));
|
||||
//add(&" ");
|
||||
//{
|
||||
//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(selection)))),
|
||||
////Fill::x(Align::w(FieldH(theme, format!("History ({})", hist_len),
|
||||
////hist_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)))));
|
||||
//////}
|
||||
//}
|
||||
//}))
|
||||
//}
|
||||
//pub fn view_status_v (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//self.update_clock();
|
||||
//let cache = self.project.clock.view_cache.read().unwrap();
|
||||
//let theme = self.color;
|
||||
//let playing = self.clock().is_rolling();
|
||||
//Tui::bg(theme.darker.rgb, Fixed::xy(20, 5, Outer(true, Style::default().fg(Tui::g(96))).enclose(
|
||||
//col!(
|
||||
//Fill::x(Align::w(Bsp::e(
|
||||
//Align::w(Tui::bg(if playing { Rgb(0, 128, 0) } else { Rgb(128, 64, 0) },
|
||||
//Either::new(false, // TODO
|
||||
//Thunk::new(move||Fixed::x(9, Either::new(playing,
|
||||
//Tui::fg(Rgb(0, 255, 0), " PLAYING "),
|
||||
//Tui::fg(Rgb(255, 128, 0), " STOPPED ")))
|
||||
//),
|
||||
//Thunk::new(move||Fixed::x(5, Either::new(playing,
|
||||
//Tui::fg(Rgb(0, 255, 0), Bsp::s(" 🭍🭑🬽 ", " 🭞🭜🭘 ",)),
|
||||
//Tui::fg(Rgb(255, 128, 0), Bsp::s(" ▗▄▖ ", " ▝▀▘ ",))))
|
||||
//)
|
||||
//)
|
||||
//)),
|
||||
//Bsp::s(
|
||||
//FieldH(theme, "Beat", cache.beat.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, "SR ", cache.sr.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<'_> {
|
||||
//self.update_clock();
|
||||
//let cache = self.project.clock.view_cache.read().unwrap();
|
||||
//view_status(Some(self.project.selection.describe(self.tracks(), self.scenes())),
|
||||
//cache.sr.view.clone(), cache.buf.view.clone(), cache.lat.view.clone())
|
||||
//}
|
||||
//pub fn view_transport (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//self.update_clock();
|
||||
//let cache = self.project.clock.view_cache.read().unwrap();
|
||||
//view_transport(self.project.clock.is_rolling(),
|
||||
//cache.bpm.view.clone(), cache.beat.view.clone(), cache.time.view.clone())
|
||||
//}
|
||||
//pub fn view_editor (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//let bg = self.editor()
|
||||
//.and_then(|editor|editor.clip().clone())
|
||||
//.map(|clip|clip.read().unwrap().color.darker)
|
||||
//.unwrap_or(self.color.darker);
|
||||
//Fill::xy(Tui::bg(bg.rgb, self.editor()))
|
||||
//}
|
||||
//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(
|
||||
//Fill::y(Align::n(Bsp::s(e.clip_status(), e.edit_status()))))))
|
||||
//}
|
||||
//pub fn view_midi_ins_status (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//self.project.view_midi_ins_status(self.color)
|
||||
//}
|
||||
//pub fn view_midi_outs_status (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//self.project.view_midi_outs_status(self.color)
|
||||
//}
|
||||
//pub fn view_audio_ins_status (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//self.project.view_audio_ins_status(self.color)
|
||||
//}
|
||||
//pub fn view_audio_outs_status (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//self.project.view_audio_outs_status(self.color)
|
||||
//}
|
||||
//pub fn view_scenes (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//Bsp::e(
|
||||
//Fixed::x(20, Align::nw(self.project.view_scenes_names())),
|
||||
//self.project.view_scenes_clips(),
|
||||
//)
|
||||
//}
|
||||
//pub fn view_scenes_names (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//self.project.view_scenes_names()
|
||||
//}
|
||||
//pub fn view_scenes_clips (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//self.project.view_scenes_clips()
|
||||
//}
|
||||
//pub fn view_tracks_inputs <'a> (&'a self) -> impl Content<TuiOut> + use<'a> {
|
||||
//Fixed::y(1 + self.project.midi_ins.len() as u16,
|
||||
//self.project.view_inputs(self.color))
|
||||
//}
|
||||
//pub fn view_tracks_outputs <'a> (&'a self) -> impl Content<TuiOut> + use<'a> {
|
||||
//self.project.view_outputs(self.color)
|
||||
//}
|
||||
//pub fn view_tracks_devices <'a> (&'a self) -> impl Content<TuiOut> + use<'a> {
|
||||
//Fixed::y(4, self.project.view_track_devices(self.color))
|
||||
//}
|
||||
//pub fn view_tracks_names <'a> (&'a self) -> impl Content<TuiOut> + use<'a> {
|
||||
//Fixed::y(2, self.project.view_track_names(self.color))
|
||||
//}
|
||||
//pub fn view_pool (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//Fixed::x(20, Bsp::s(
|
||||
//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)))
|
||||
//.enclose(PoolView(&self.pool)))))))
|
||||
//}
|
||||
//pub fn view_samples_keys (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//self.project.sampler().map(|s|s.view_list(true, self.editor().unwrap()))
|
||||
//}
|
||||
//pub fn view_samples_grid (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//self.project.sampler().map(|s|s.view_grid())
|
||||
//}
|
||||
//pub fn view_sample_viewer (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//self.project.sampler().map(|s|s.view_sample(self.editor().unwrap().get_note_pos()))
|
||||
//}
|
||||
//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()))
|
||||
//}
|
||||
//pub fn view_sample_status (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//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())))))
|
||||
//}
|
||||
////let options = ||["Projects", "Settings", "Help", "Quit"].iter();
|
||||
////let option = |a,i|Tui::fg(Rgb(255,255,255), format!("{}", a));
|
||||
////Bsp::s(Tui::bold(true, "tek!"), Bsp::s("", Map::south(1, options, option)))
|
||||
|
|
|
|||
156
crates/app/app_bind.rs
Normal file
156
crates/app/app_bind.rs
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
use crate::*;
|
||||
|
||||
impl<'t> DslNs<'t, AppCommand> for App {
|
||||
dsl_exprs!(|app| -> AppCommand {
|
||||
});
|
||||
dsl_words!(|app| -> AppCommand {
|
||||
"x/inc" => todo!(),
|
||||
"x/dec" => todo!(),
|
||||
"y/inc" => todo!(),
|
||||
"y/dec" => todo!(),
|
||||
"confirm" => todo!(),
|
||||
});
|
||||
}
|
||||
|
||||
//AppCommand => {
|
||||
//("x/inc" /
|
||||
//("stop-all") => todo!(),//app.project.stop_all(),
|
||||
//("enqueue", clip: Option<Arc<RwLock<MidiClip>>>) => todo!(),
|
||||
//("history", delta: isize) => todo!(),
|
||||
//("zoom", zoom: usize) => todo!(),
|
||||
//("select", selection: Selection) => todo!(),
|
||||
//("dialog" / command: DialogCommand) => todo!(),
|
||||
//("project" / command: ArrangementCommand) => todo!(),
|
||||
//("clock" / command: ClockCommand) => todo!(),
|
||||
//("sampler" / command: SamplerCommand) => todo!(),
|
||||
//("pool" / command: PoolCommand) => todo!(),
|
||||
//("edit" / editor: MidiEditCommand) => todo!(),
|
||||
//};
|
||||
|
||||
//DialogCommand;
|
||||
|
||||
//ArrangementCommand;
|
||||
|
||||
//ClockCommand;
|
||||
|
||||
//SamplerCommand;
|
||||
|
||||
//PoolCommand;
|
||||
|
||||
//MidiEditCommand;
|
||||
|
||||
|
||||
//take!(DialogCommand |state: App, iter|Take::take(&state.dialog, iter));
|
||||
//#[derive(Clone, Debug)]
|
||||
//pub enum DialogCommand {
|
||||
//Open { dialog: Dialog },
|
||||
//Close
|
||||
//}
|
||||
|
||||
//impl Command<Option<Dialog>> for DialogCommand {
|
||||
//fn execute (self, state: &mut Option<Dialog>) -> Perhaps<Self> {
|
||||
//match self {
|
||||
//Self::Open { dialog } => {
|
||||
//*state = Some(dialog);
|
||||
//},
|
||||
//Self::Close => {
|
||||
//*state = None;
|
||||
//}
|
||||
//};
|
||||
//Ok(None)
|
||||
//}
|
||||
//}
|
||||
|
||||
//dsl!(DialogCommand: |self: Dialog, iter|todo!());
|
||||
//Dsl::take(&mut self.dialog, iter));
|
||||
|
||||
//#[tengri_proc::command(Option<Dialog>)]//Nope.
|
||||
//impl DialogCommand {
|
||||
//fn open (dialog: &mut Option<Dialog>, new: Dialog) -> Perhaps<Self> {
|
||||
//*dialog = Some(new);
|
||||
//Ok(None)
|
||||
//}
|
||||
//fn close (dialog: &mut Option<Dialog>) -> Perhaps<Self> {
|
||||
//*dialog = None;
|
||||
//Ok(None)
|
||||
//}
|
||||
//}
|
||||
//
|
||||
//dsl_bind!(AppCommand: App {
|
||||
//enqueue = |app, clip: Option<Arc<RwLock<MidiClip>>>| { todo!() };
|
||||
//history = |app, delta: isize| { todo!() };
|
||||
//zoom = |app, zoom: usize| { todo!() };
|
||||
//stop_all = |app| { app.tracks_stop_all(); Ok(None) };
|
||||
////dialog = |app, command: DialogCommand|
|
||||
////Ok(command.delegate(&mut app.dialog, |c|Self::Dialog{command: c})?);
|
||||
//project = |app, command: ArrangementCommand|
|
||||
//Ok(command.delegate(&mut app.project, |c|Self::Project{command: c})?);
|
||||
//clock = |app, command: ClockCommand|
|
||||
//Ok(command.execute(app.clock_mut())?.map(|c|Self::Clock{command: c}));
|
||||
//sampler = |app, command: SamplerCommand|
|
||||
//Ok(app.project.sampler_mut().map(|s|command.delegate(s, |command|Self::Sampler{command}))
|
||||
//.transpose()?.flatten());
|
||||
//pool = |app, command: PoolCommand| {
|
||||
//let undo = command.clone().delegate(&mut app.pool, |command|AppCommand::Pool{command})?;
|
||||
//// update linked editor after pool action
|
||||
//match command {
|
||||
//// autoselect: automatically load selected clip in editor
|
||||
//PoolCommand::Select { .. } |
|
||||
//// autocolor: update color in all places simultaneously
|
||||
//PoolCommand::Clip { command: PoolClipCommand::SetColor { .. } } => {
|
||||
//let clip = app.pool.clip().clone();
|
||||
//app.editor_mut().map(|editor|editor.set_clip(clip.as_ref()))
|
||||
//},
|
||||
//_ => None
|
||||
//};
|
||||
//Ok(undo)
|
||||
//};
|
||||
//select = |app, selection: Selection| {
|
||||
//*app.project.selection_mut() = selection;
|
||||
////todo!
|
||||
////if let Some(ref mut editor) = app.editor_mut() {
|
||||
////editor.set_clip(match selection {
|
||||
////Selection::TrackClip { track, scene } if let Some(Some(Some(clip))) = app
|
||||
////.project
|
||||
////.scenes.get(scene)
|
||||
////.map(|s|s.clips.get(track))
|
||||
////=>
|
||||
////Some(clip),
|
||||
////_ =>
|
||||
////None
|
||||
////});
|
||||
////}
|
||||
//Ok(None)
|
||||
////("select" [t: usize, s: usize] Some(match (t.expect("no track"), s.expect("no scene")) {
|
||||
////(0, 0) => Self::Select(Selection::Mix),
|
||||
////(t, 0) => Self::Select(Selection::Track(t)),
|
||||
////(0, s) => Self::Select(Selection::Scene(s)),
|
||||
////(t, s) => Self::Select(Selection::TrackClip { track: t, scene: s }) })))
|
||||
//// autoedit: load focused clip in editor.
|
||||
//};
|
||||
////fn color (app: &mut App, theme: ItemTheme) -> Perhaps<Self> {
|
||||
////Ok(app.set_color(Some(theme)).map(|theme|Self::Color{theme}))
|
||||
////}
|
||||
////fn launch (app: &mut App) -> Perhaps<Self> {
|
||||
////app.project.launch();
|
||||
////Ok(None)
|
||||
////}
|
||||
//toggle_editor = |app, value: bool|{ app.toggle_editor(Some(value)); Ok(None) };
|
||||
//editor = |app, command: MidiEditCommand| Ok(if let Some(editor) = app.editor_mut() {
|
||||
//let undo = command.clone().delegate(editor, |command|AppCommand::Editor{command})?;
|
||||
//// update linked sampler after editor action
|
||||
//app.project.sampler_mut().map(|sampler|match command {
|
||||
//// autoselect: automatically select sample in sampler
|
||||
//MidiEditCommand::SetNotePos { pos } => { sampler.set_note_pos(pos); },
|
||||
//_ => {}
|
||||
//});
|
||||
//undo
|
||||
//} else {
|
||||
//None
|
||||
//});
|
||||
//});
|
||||
//take!(ClockCommand |state: App, iter|Take::take(state.clock(), iter));
|
||||
//take!(MidiEditCommand |state: App, iter|Ok(state.editor().map(|x|Take::take(x, iter)).transpose()?.flatten()));
|
||||
//take!(PoolCommand |state: App, iter|Take::take(&state.pool, iter));
|
||||
//take!(SamplerCommand |state: App, iter|Ok(state.project.sampler().map(|x|Take::take(x, iter)).transpose()?.flatten()));
|
||||
//take!(ArrangementCommand |state: App, iter|Take::take(&state.project, iter));
|
||||
327
crates/app/app_view.rs
Normal file
327
crates/app/app_view.rs
Normal file
|
|
@ -0,0 +1,327 @@
|
|||
use crate::*;
|
||||
|
||||
impl<'t> DslNs<'t, Box<dyn Render<TuiOut>>> for App {
|
||||
dsl_exprs!(|app| -> Box<dyn Render<TuiOut>> {
|
||||
"fg" (color: Color, x: Box<dyn Render<TuiOut>>) => Box::new(Tui::fg(color, x)),
|
||||
"bg" (color: Color, x: Box<dyn Render<TuiOut>>) => Box::new(Tui::bg(color, x)),
|
||||
"fg/bg" (fg: Color, bg: Color, x: Box<dyn Render<TuiOut>>) => Box::new(Tui::fg_bg(fg, bg, x)),
|
||||
|
||||
"bsp/n" (a: Box<dyn Render<TuiOut>>, b: Box<dyn Render<TuiOut>>) => Box::new(Bsp::n(a, b)),
|
||||
"bsp/s" (a: Box<dyn Render<TuiOut>>, b: Box<dyn Render<TuiOut>>) => Box::new(Bsp::s(a, b)),
|
||||
"bsp/e" (a: Box<dyn Render<TuiOut>>, b: Box<dyn Render<TuiOut>>) => Box::new(Bsp::e(a, b)),
|
||||
"bsp/w" (a: Box<dyn Render<TuiOut>>, b: Box<dyn Render<TuiOut>>) => Box::new(Bsp::w(a, b)),
|
||||
"bsp/a" (a: Box<dyn Render<TuiOut>>, b: Box<dyn Render<TuiOut>>) => Box::new(Bsp::a(a, b)),
|
||||
"bsp/b" (a: Box<dyn Render<TuiOut>>, b: Box<dyn Render<TuiOut>>) => Box::new(Bsp::b(a, b)),
|
||||
|
||||
"align/n" (x: Box<dyn Render<TuiOut>>) => Box::new(Align::n(x)),
|
||||
"align/s" (x: Box<dyn Render<TuiOut>>) => Box::new(Align::s(x)),
|
||||
"align/e" (x: Box<dyn Render<TuiOut>>) => Box::new(Align::e(x)),
|
||||
"align/w" (x: Box<dyn Render<TuiOut>>) => Box::new(Align::w(x)),
|
||||
"align/x" (x: Box<dyn Render<TuiOut>>) => Box::new(Align::x(x)),
|
||||
"align/y" (x: Box<dyn Render<TuiOut>>) => Box::new(Align::y(x)),
|
||||
"align/c" (x: Box<dyn Render<TuiOut>>) => Box::new(Align::c(x)),
|
||||
|
||||
"fill/x" (x: Box<dyn Render<TuiOut>>) => Box::new(Fill::x(x)),
|
||||
"fill/y" (x: Box<dyn Render<TuiOut>>) => Box::new(Fill::y(x)),
|
||||
"fill/xy" (x: Box<dyn Render<TuiOut>>) => Box::new(Fill::xy(x)),
|
||||
|
||||
"fixed/x" (x: u16, c: Box<dyn Render<TuiOut>>) => Box::new(Fixed::x(x, c)),
|
||||
"fixed/y" (y: u16, c: Box<dyn Render<TuiOut>>) => Box::new(Fixed::y(y, c)),
|
||||
"fixed/xy" (x: u16, y: u16, c: Box<dyn Render<TuiOut>>) => Box::new(Fixed::xy(x, y, c)),
|
||||
|
||||
"min/x" (x: u16, c: Box<dyn Render<TuiOut>>) => Box::new(Min::x(x, c)),
|
||||
"min/y" (y: u16, c: Box<dyn Render<TuiOut>>) => Box::new(Min::y(y, c)),
|
||||
"min/xy" (x: u16, y: u16, c: Box<dyn Render<TuiOut>>) => Box::new(Min::xy(x, y, c)),
|
||||
|
||||
"max/x" (x: u16, c: Box<dyn Render<TuiOut>>) => Box::new(Max::x(x, c)),
|
||||
"max/y" (y: u16, c: Box<dyn Render<TuiOut>>) => Box::new(Max::y(y, c)),
|
||||
"max/xy" (x: u16, y: u16, c: Box<dyn Render<TuiOut>>) => Box::new(Max::xy(x, y, c)),
|
||||
});
|
||||
dsl_words!(|app| -> Box<dyn Render<TuiOut>> {
|
||||
":templates" => Box::new({
|
||||
let modes = app.config.modes.clone();
|
||||
let height = (modes.read().unwrap().len() * 2) as u16;
|
||||
Min::x(30, Fixed::y(height, Stack::south(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
|
||||
for (index, (id, profile)) in modes.read().unwrap().iter().enumerate() {
|
||||
let bg = if index == 0 { Rgb(48,64,32) } else { Rgb(16, 32, 24) };
|
||||
let name = profile.name.get(0).map(|x|x.as_ref()).unwrap_or("<no name>");
|
||||
let info = profile.info.get(0).map(|x|x.as_ref()).unwrap_or("<no info>");
|
||||
let fg1 = Rgb(224, 192, 128);
|
||||
let fg2 = Rgb(224, 128, 32);
|
||||
add(&Fixed::y(2, Fill::x(Tui::bg(bg, Bsp::s(
|
||||
Bsp::a(Fill::x(Align::w(Tui::fg(fg1, name))),
|
||||
Fill::x(Align::e(Tui::fg(fg2, id)))),
|
||||
Align::w(info))))));
|
||||
}})))}),
|
||||
":sessions" => Box::new(Min::x(30, Fixed::y(6, Stack::south(
|
||||
move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
|
||||
let fg = Rgb(224, 192, 128);
|
||||
for (index, name) in ["session1", "session2", "session3"].iter().enumerate() {
|
||||
let bg = if index == 0 { Rgb(48,64,32) } else { Rgb(16, 32, 24) };
|
||||
add(&Fixed::y(2, Fill::x(Tui::bg(bg, Align::w(Tui::fg(fg, name))))));
|
||||
}
|
||||
}
|
||||
)))),
|
||||
":browse/title" => Box::new(Fill::x(Align::w(FieldV(Default::default(),
|
||||
match app.dialog.browser_target().unwrap() {
|
||||
BrowserTarget::SaveProject => "Save project:",
|
||||
BrowserTarget::LoadProject => "Load project:",
|
||||
BrowserTarget::ImportSample(_) => "Import sample:",
|
||||
BrowserTarget::ExportSample(_) => "Export sample:",
|
||||
BrowserTarget::ImportClip(_) => "Import clip:",
|
||||
BrowserTarget::ExportClip(_) => "Export clip:",
|
||||
}, Shrink::x(3, Fixed::y(1, Tui::fg(Tui::g(96), RepeatH("🭻")))))))),
|
||||
":device" => {
|
||||
let selected = app.dialog.device_kind().unwrap();
|
||||
Box::new(Bsp::s(Tui::bold(true, "Add device"), Map::south(1,
|
||||
move||device_kinds().iter(),
|
||||
move|label: &&'static str, i|{
|
||||
let bg = if i == selected { Rgb(64,128,32) } else { Rgb(0,0,0) };
|
||||
let lb = if i == selected { "[ " } else { " " };
|
||||
let rb = if i == selected { " ]" } else { " " };
|
||||
Fill::x(Tui::bg(bg, Bsp::e(lb, Bsp::w(rb, "FIXME device name")))) }))) },
|
||||
});
|
||||
/// Resolve an expression if known.
|
||||
fn from_expr <D: Dsl> (&'t self, dsl: D) -> Perhaps<Box<dyn Render<TuiOut>>> {
|
||||
if let Some(head) = dsl.expr().head()? {
|
||||
for (key, value) in Self::EXPRS.0.iter() {
|
||||
if head == *key {
|
||||
return value(self, dsl.expr().tail()?.unwrap_or(""))
|
||||
}
|
||||
}
|
||||
}
|
||||
return Ok(None)
|
||||
}
|
||||
/// Resolve a symbol if known.
|
||||
fn from_word <D: Dsl> (&'t self, dsl: D) -> Perhaps<Box<dyn Render<TuiOut>>> {
|
||||
if let Some(dsl) = dsl.word()? {
|
||||
let views = self.config.views.read().unwrap();
|
||||
if let Some(view) = views.get(dsl) {
|
||||
let view = view.clone();
|
||||
std::mem::drop(views);
|
||||
return Ok(Some(render_dsl(self, view.as_ref())))
|
||||
}
|
||||
for (word, get) in Self::WORDS.0 { if dsl == *word { return get(self) } }
|
||||
}
|
||||
return Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
//Bsp::s("",
|
||||
//Map::south(1,
|
||||
//move||app.config.binds.layers.iter()
|
||||
//.filter_map(|a|(a.0)(app).then_some(a.1))
|
||||
//.flat_map(|a|a)
|
||||
//.filter_map(|x|if let Value::Exp(_, iter)=x.value{ Some(iter) } else { None })
|
||||
//.skip(offset)
|
||||
//.take(20),
|
||||
//|mut b,i|Fixed::x(60, Align::w(Bsp::e("(", Bsp::e(
|
||||
//b.next().map(|t|Fixed::x(16, Align::w(Tui::fg(Rgb(64,224,0), format!("{}", t.value))))),
|
||||
//Bsp::e(" ", Align::w(format!("{}", b.0.0.trim()))))))))))),
|
||||
|
||||
//Dialog::Browser(BrowserTarget::Load, browser) => {
|
||||
//"bobcat".boxed()
|
||||
////Bsp::s(
|
||||
////Fill::x(Align::w(Margin::xy(1, 1, Bsp::e(
|
||||
////Tui::bold(true, " Load project: "),
|
||||
////Shrink::x(3, Fixed::y(1, RepeatH("🭻"))))))),
|
||||
////Outer(true, Style::default().fg(Tui::g(96)))
|
||||
////.enclose(Fill::xy(browser)))
|
||||
//},
|
||||
//Dialog::Browser(BrowserTarget::Export, browser) => {
|
||||
//"bobcat".boxed()
|
||||
////Bsp::s(
|
||||
////Fill::x(Align::w(Margin::xy(1, 1, Bsp::e(
|
||||
////Tui::bold(true, " Export: "),
|
||||
////Shrink::x(3, Fixed::y(1, RepeatH("🭻"))))))),
|
||||
////Outer(true, Style::default().fg(Tui::g(96)))
|
||||
////.enclose(Fill::xy(browser)))
|
||||
//},
|
||||
//Dialog::Browser(BrowserTarget::Import, browser) => {
|
||||
//"bobcat".boxed()
|
||||
////Bsp::s(
|
||||
////Fill::x(Align::w(Margin::xy(1, 1, Bsp::e(
|
||||
////Tui::bold(true, " Import: "),
|
||||
////Shrink::x(3, Fixed::y(1, RepeatH("🭻"))))))),
|
||||
////Outer(true, Style::default().fg(Tui::g(96)))
|
||||
////.enclose(Fill::xy(browser)))
|
||||
//},
|
||||
//
|
||||
//pub fn view_meters_input (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//self.project.sampler().map(|s|
|
||||
//s.view_meters_input())
|
||||
//}
|
||||
//pub fn view_meters_output (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//self.project.sampler().map(|s|
|
||||
//s.view_meters_output())
|
||||
//}
|
||||
//pub fn view_history (&self) -> impl Content<TuiOut> {
|
||||
//Fixed::y(1, Fill::x(Align::w(FieldH(self.color,
|
||||
//format!("History ({})", self.history.len()),
|
||||
//self.history.last().map(|last|Fill::x(Align::w(format!("{:?}", last.0))))))))
|
||||
//}
|
||||
//pub fn view_status_h2 (&self) -> impl Content<TuiOut> {
|
||||
//self.update_clock();
|
||||
//let theme = self.color;
|
||||
//let clock = self.clock();
|
||||
//let playing = clock.is_rolling();
|
||||
//let cache = clock.view_cache.clone();
|
||||
////let selection = self.selection().describe(self.tracks(), self.scenes());
|
||||
//let hist_len = self.history.len();
|
||||
//let hist_last = self.history.last();
|
||||
//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) },
|
||||
//Either::new(false, // TODO
|
||||
//Thunk::new(move||Fixed::x(9, Either::new(playing,
|
||||
//Tui::fg(Rgb(0, 255, 0), " PLAYING "),
|
||||
//Tui::fg(Rgb(255, 128, 0), " STOPPED ")))
|
||||
//),
|
||||
//Thunk::new(move||Fixed::x(5, Either::new(playing,
|
||||
//Tui::fg(Rgb(0, 255, 0), Bsp::s(" 🭍🭑🬽 ", " 🭞🭜🭘 ",)),
|
||||
//Tui::fg(Rgb(255, 128, 0), Bsp::s(" ▗▄▖ ", " ▝▀▘ ",))))
|
||||
//)
|
||||
//)
|
||||
//)));
|
||||
//add(&" ");
|
||||
//{
|
||||
//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(selection)))),
|
||||
////Fill::x(Align::w(FieldH(theme, format!("History ({})", hist_len),
|
||||
////hist_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)))));
|
||||
//////}
|
||||
//}
|
||||
//}))
|
||||
//}
|
||||
//pub fn view_status_v (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//self.update_clock();
|
||||
//let cache = self.project.clock.view_cache.read().unwrap();
|
||||
//let theme = self.color;
|
||||
//let playing = self.clock().is_rolling();
|
||||
//Tui::bg(theme.darker.rgb, Fixed::xy(20, 5, Outer(true, Style::default().fg(Tui::g(96))).enclose(
|
||||
//col!(
|
||||
//Fill::x(Align::w(Bsp::e(
|
||||
//Align::w(Tui::bg(if playing { Rgb(0, 128, 0) } else { Rgb(128, 64, 0) },
|
||||
//Either::new(false, // TODO
|
||||
//Thunk::new(move||Fixed::x(9, Either::new(playing,
|
||||
//Tui::fg(Rgb(0, 255, 0), " PLAYING "),
|
||||
//Tui::fg(Rgb(255, 128, 0), " STOPPED ")))
|
||||
//),
|
||||
//Thunk::new(move||Fixed::x(5, Either::new(playing,
|
||||
//Tui::fg(Rgb(0, 255, 0), Bsp::s(" 🭍🭑🬽 ", " 🭞🭜🭘 ",)),
|
||||
//Tui::fg(Rgb(255, 128, 0), Bsp::s(" ▗▄▖ ", " ▝▀▘ ",))))
|
||||
//)
|
||||
//)
|
||||
//)),
|
||||
//Bsp::s(
|
||||
//FieldH(theme, "Beat", cache.beat.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, "SR ", cache.sr.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<'_> {
|
||||
//self.update_clock();
|
||||
//let cache = self.project.clock.view_cache.read().unwrap();
|
||||
//view_status(Some(self.project.selection.describe(self.tracks(), self.scenes())),
|
||||
//cache.sr.view.clone(), cache.buf.view.clone(), cache.lat.view.clone())
|
||||
//}
|
||||
//pub fn view_transport (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//self.update_clock();
|
||||
//let cache = self.project.clock.view_cache.read().unwrap();
|
||||
//view_transport(self.project.clock.is_rolling(),
|
||||
//cache.bpm.view.clone(), cache.beat.view.clone(), cache.time.view.clone())
|
||||
//}
|
||||
//pub fn view_editor (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//let bg = self.editor()
|
||||
//.and_then(|editor|editor.clip().clone())
|
||||
//.map(|clip|clip.read().unwrap().color.darker)
|
||||
//.unwrap_or(self.color.darker);
|
||||
//Fill::xy(Tui::bg(bg.rgb, self.editor()))
|
||||
//}
|
||||
//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(
|
||||
//Fill::y(Align::n(Bsp::s(e.clip_status(), e.edit_status()))))))
|
||||
//}
|
||||
//pub fn view_midi_ins_status (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//self.project.view_midi_ins_status(self.color)
|
||||
//}
|
||||
//pub fn view_midi_outs_status (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//self.project.view_midi_outs_status(self.color)
|
||||
//}
|
||||
//pub fn view_audio_ins_status (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//self.project.view_audio_ins_status(self.color)
|
||||
//}
|
||||
//pub fn view_audio_outs_status (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//self.project.view_audio_outs_status(self.color)
|
||||
//}
|
||||
//pub fn view_scenes (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//Bsp::e(
|
||||
//Fixed::x(20, Align::nw(self.project.view_scenes_names())),
|
||||
//self.project.view_scenes_clips(),
|
||||
//)
|
||||
//}
|
||||
//pub fn view_scenes_names (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//self.project.view_scenes_names()
|
||||
//}
|
||||
//pub fn view_scenes_clips (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//self.project.view_scenes_clips()
|
||||
//}
|
||||
//pub fn view_tracks_inputs <'a> (&'a self) -> impl Content<TuiOut> + use<'a> {
|
||||
//Fixed::y(1 + self.project.midi_ins.len() as u16,
|
||||
//self.project.view_inputs(self.color))
|
||||
//}
|
||||
//pub fn view_tracks_outputs <'a> (&'a self) -> impl Content<TuiOut> + use<'a> {
|
||||
//self.project.view_outputs(self.color)
|
||||
//}
|
||||
//pub fn view_tracks_devices <'a> (&'a self) -> impl Content<TuiOut> + use<'a> {
|
||||
//Fixed::y(4, self.project.view_track_devices(self.color))
|
||||
//}
|
||||
//pub fn view_tracks_names <'a> (&'a self) -> impl Content<TuiOut> + use<'a> {
|
||||
//Fixed::y(2, self.project.view_track_names(self.color))
|
||||
//}
|
||||
//pub fn view_pool (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//Fixed::x(20, Bsp::s(
|
||||
//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)))
|
||||
//.enclose(PoolView(&self.pool)))))))
|
||||
//}
|
||||
//pub fn view_samples_keys (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//self.project.sampler().map(|s|s.view_list(true, self.editor().unwrap()))
|
||||
//}
|
||||
//pub fn view_samples_grid (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//self.project.sampler().map(|s|s.view_grid())
|
||||
//}
|
||||
//pub fn view_sample_viewer (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//self.project.sampler().map(|s|s.view_sample(self.editor().unwrap().get_note_pos()))
|
||||
//}
|
||||
//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()))
|
||||
//}
|
||||
//pub fn view_sample_status (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//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())))))
|
||||
//}
|
||||
////let options = ||["Projects", "Settings", "Help", "Quit"].iter();
|
||||
////let option = |a,i|Tui::fg(Rgb(255,255,255), format!("{}", a));
|
||||
////Bsp::s(Tui::bold(true, "tek!"), Bsp::s("", Map::south(1, options, option)))
|
||||
|
|
@ -73,16 +73,13 @@ impl Cli {
|
|||
midi_outs.push(jack.midi_out(&format!("{index}/M"), &[connect.clone()])?);
|
||||
};
|
||||
let clock = Clock::new(&jack, self.bpm)?;
|
||||
let mode = config.modes.clone().read().unwrap().get(":menu").cloned().unwrap();
|
||||
let app = App {
|
||||
config,
|
||||
jack: jack.clone(),
|
||||
color: ItemTheme::random(),
|
||||
dialog: Dialog::Menu(0),
|
||||
mode: Mode {
|
||||
view: vec![":menu".into()],
|
||||
keys: vec![":y".into()],
|
||||
..Default::default()
|
||||
},
|
||||
mode,
|
||||
config,
|
||||
project: Arrangement {
|
||||
name: Default::default(),
|
||||
color: ItemTheme::random(),
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ impl ArrangementCommand {
|
|||
Ok(None)
|
||||
//TODO:Ok(Some(Self::TrackAdd ( index, track: Some(deleted_track) })
|
||||
}
|
||||
fn midi_in (arranger: &mut Arrangement, input: MidiInputCommand) -> Perhaps<Self> {
|
||||
fn midi_in (_arranger: &mut Arrangement, _input: MidiInputCommand) -> Perhaps<Self> {
|
||||
todo!("delegate");
|
||||
Ok(None)
|
||||
}
|
||||
|
|
@ -133,7 +133,7 @@ impl ArrangementCommand {
|
|||
arranger.midi_in_add()?;
|
||||
Ok(None)
|
||||
}
|
||||
fn midi_out (arranger: &mut Arrangement, input: MidiOutputCommand) -> Perhaps<Self> {
|
||||
fn midi_out (_arranger: &mut Arrangement, _input: MidiOutputCommand) -> Perhaps<Self> {
|
||||
todo!("delegate");
|
||||
Ok(None)
|
||||
}
|
||||
|
|
@ -141,11 +141,11 @@ impl ArrangementCommand {
|
|||
arranger.midi_out_add()?;
|
||||
Ok(None)
|
||||
}
|
||||
fn device (arranger: &mut Arrangement, input: DeviceCommand) -> Perhaps<Self> {
|
||||
fn device (_arranger: &mut Arrangement, _input: DeviceCommand) -> Perhaps<Self> {
|
||||
todo!("delegate");
|
||||
Ok(None)
|
||||
}
|
||||
fn device_add (arranger: &mut Arrangement, i: usize) -> Perhaps<Self> {
|
||||
fn device_add (_arranger: &mut Arrangement, _i: usize) -> Perhaps<Self> {
|
||||
todo!("delegate");
|
||||
Ok(None)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue