mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
woohoo!
This commit is contained in:
parent
525ed15466
commit
525a455f7a
2 changed files with 69 additions and 49 deletions
|
|
@ -243,9 +243,19 @@ fn unquote (x: &str) -> &str {
|
|||
chars.as_str()
|
||||
}
|
||||
impl Dialog {
|
||||
fn menu_selected (&self) -> Option<usize> { todo!() }
|
||||
fn device_selected (&self) -> Option<usize> { todo!() }
|
||||
fn message (&self) -> Option<&str> { todo!() }
|
||||
fn browser (&self) -> Option<&Arc<Browser>> { todo!() }
|
||||
fn browser_target (&self) -> Option<&BrowserTarget> { todo!() }
|
||||
fn menu_selected (&self) -> Option<usize> {
|
||||
if let Self::Menu(selected) = self { Some(*selected) } else { None }
|
||||
}
|
||||
fn device_selected (&self) -> Option<usize> {
|
||||
if let Self::Device(selected) = self { Some(*selected) } else { None }
|
||||
}
|
||||
fn message (&self) -> Option<&str> {
|
||||
todo!()
|
||||
}
|
||||
fn browser (&self) -> Option<&Arc<Browser>> {
|
||||
todo!()
|
||||
}
|
||||
fn browser_target (&self) -> Option<&BrowserTarget> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,38 +16,41 @@ impl<'t, D: Dsl> std::ops::Index<D> for DslNs<'t, DslCb> {
|
|||
}
|
||||
}
|
||||
pub const VIEW: DslNs<'static, DslCb> = DslNs(&[
|
||||
(":view", |state|VIEW[":view/content"](state)),
|
||||
(":view/content", |state|Fill::xy(ErrorBoundary::new(Ok(Some("·")))).boxed()),
|
||||
(":view/overlay", |state|{
|
||||
match &state.dialog {
|
||||
|
||||
(":view", |state|Box::new(
|
||||
Fill::xy(Bsp::a(VIEW[":view/content"](state), VIEW[":view/overlay"](state))))),
|
||||
|
||||
(":view/content", |state|Box::new(
|
||||
Fill::xy(ErrorBoundary::new(Ok(Some("·")))))),
|
||||
|
||||
(":view/overlay", |state|match &state.dialog {
|
||||
Dialog::Menu(_) => VIEW[":view/menu"](state),
|
||||
Dialog::Device(_) => VIEW[":view/device"](state),
|
||||
Dialog::Browser(_, _) => VIEW[":view/browser"](state),
|
||||
Dialog::Browser(_, _) => VIEW[":view/browse"](state),
|
||||
//Dialog::Help(_) => view_help,
|
||||
//Dialog::Message(_) => view_message,
|
||||
//Dialog::Options => view_options,
|
||||
_ => unimplemented!()
|
||||
}
|
||||
}),
|
||||
(":view/browser", |state|{
|
||||
_ => unimplemented!() }),
|
||||
|
||||
(":view/browse", |state|{
|
||||
let browser = state.dialog.browser().cloned().unwrap();
|
||||
let target = state.dialog.browser_target().unwrap();
|
||||
Box::new(Bsp::s(
|
||||
Padding::xy(3, 1, Fill::x(Align::w(FieldV(
|
||||
Default::default(),
|
||||
match target {
|
||||
Padding::xy(3, 1, VIEW[":view/browse-title"](state)),
|
||||
Outer(true, Style::default().fg(Tui::g(96)))
|
||||
.enclose(Fill::xy(browser)))) }),
|
||||
|
||||
(":view/browse-title", |state: &App|{
|
||||
let target = state.dialog.browser_target().unwrap();
|
||||
Box::new(Fill::x(Align::w(FieldV(Default::default(), match target {
|
||||
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("🭻")))))))),
|
||||
Outer(true, Style::default().fg(Tui::g(96)))
|
||||
.enclose(Fill::xy(browser))))
|
||||
}),
|
||||
(":view/device", |state|{
|
||||
}, Shrink::x(3, Fixed::y(1, Tui::fg(Tui::g(96), RepeatH("🭻"))))))))}),
|
||||
|
||||
(":view/device", |state: &App|{
|
||||
let selected = state.dialog.device_selected().unwrap();
|
||||
Box::new(Bsp::s(Tui::bold(true, "Add device"), Map::south(1,
|
||||
move||device_kinds().iter(),
|
||||
|
|
@ -55,20 +58,23 @@ pub const VIEW: DslNs<'static, DslCb> = DslNs(&[
|
|||
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"))))
|
||||
})))
|
||||
}),
|
||||
Fill::x(Tui::bg(bg, Bsp::e(lb, Bsp::w(rb, "FIXME device name")))) }))) }),
|
||||
|
||||
(":view/menu", |state|{
|
||||
let views = state.config.views.clone();
|
||||
let selected = state.dialog.menu_selected();
|
||||
Box::new(Tui::bg(Rgb(0,0,0), Bsp::s(
|
||||
let outputs = Fill::x(Fixed::y(3,
|
||||
Bsp::a(Fill::x(Align::w(" L AUDIO OUTS")), Bsp::a("MIDI OUT", Fill::x(Align::e("AUDIO OUTS R "))))));
|
||||
let inputs = Fill::x(Fixed::y(3,
|
||||
Bsp::a(Fill::x(Align::w(" L AUDIO INS")), Bsp::a("MIDI INS", Fill::x(Align::e("AUDIO INS R "))))));
|
||||
Box::new(Tui::bg(Rgb(0,0,0), Bsp::s(outputs, Bsp::s(
|
||||
Fill::x(Fixed::y(3, Tui::bg(Rgb(33,33,33), Tui::bold(true, "tek 0.3.0-rc0")))),
|
||||
Bsp::n(
|
||||
Bsp::n(inputs, Bsp::n(
|
||||
Fill::x(Fixed::y(3, Tui::bg(Rgb(33,33,33), Bsp::e(Tui::fg(Rgb(255,192,48), "[Enter]"), " new session")))),
|
||||
Fill::y(Align::n(Fill::x(Stack::south(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
|
||||
////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)))
|
||||
Fill::y(Align::n(Fill::x(VIEW[":view/profiles"](state)))))))))) }),
|
||||
|
||||
(":view/profiles", |state|Box::new({
|
||||
let views = state.config.views.clone();
|
||||
Stack::south(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
|
||||
for (index, (id, profile)) in views.read().unwrap().iter().enumerate() {
|
||||
let bg = if index == 0 { Rgb(64,64,64) } else { Rgb(32,32,32) };
|
||||
let name = profile.name.as_ref().map(|x|unquote(unquote(x.as_ref())));
|
||||
|
|
@ -76,12 +82,13 @@ pub const VIEW: DslNs<'static, DslCb> = DslNs(&[
|
|||
add(&Fixed::y(3, Tui::bg(bg, Bsp::s(
|
||||
Fill::x(Bsp::a(
|
||||
Fill::x(Align::w(Tui::fg(Rgb(224,192,128), name))),
|
||||
Fill::x(Align::e(Tui::fg(Rgb(224,128,32), &id)))
|
||||
)),
|
||||
Fill::x(Align::w(info)))))); } }))))))))
|
||||
}),
|
||||
Fill::x(Align::e(Tui::fg(Rgb(224,128,32), &id))))),
|
||||
Fill::x(Align::w(info)))))); } })}))
|
||||
|
||||
|
||||
//(":view/options", view_options),
|
||||
]);
|
||||
|
||||
fn view_nil (_: &App) -> Box<dyn Render<TuiOut>> {
|
||||
"nil".boxed()
|
||||
}
|
||||
|
|
@ -316,3 +323,6 @@ impl ScenesView for App {
|
|||
//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)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue