mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
browser with target action
This commit is contained in:
parent
b7152ef807
commit
c66a006120
10 changed files with 102 additions and 56 deletions
|
|
@ -67,7 +67,7 @@ impl App {
|
|||
}
|
||||
pub fn browser (&self) -> Option<&Browser> {
|
||||
self.dialog.as_ref().and_then(|dialog|match dialog {
|
||||
Dialog::Save(b) | Dialog::Load(b) => Some(b),
|
||||
Dialog::Browser(_, b) => Some(b),
|
||||
_ => None
|
||||
})
|
||||
}
|
||||
|
|
@ -156,11 +156,20 @@ pub enum Dialog {
|
|||
Menu(usize),
|
||||
Device(usize),
|
||||
Message(Message),
|
||||
Save(Browser),
|
||||
Load(Browser),
|
||||
Browser(BrowserTarget, Browser),
|
||||
Options,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum BrowserTarget {
|
||||
SaveProject,
|
||||
LoadProject,
|
||||
ImportSample(Arc<RwLock<Option<Sample>>>),
|
||||
ExportSample(Arc<RwLock<Option<Sample>>>),
|
||||
ImportClip(Arc<RwLock<Option<MidiClip>>>),
|
||||
ExportClip(Arc<RwLock<Option<MidiClip>>>),
|
||||
}
|
||||
|
||||
/// Various possible messages
|
||||
#[derive(PartialEq, Clone, Copy, Debug)]
|
||||
pub enum Message {
|
||||
|
|
@ -235,10 +244,22 @@ impl App {
|
|||
Some(Dialog::Menu(0))
|
||||
}
|
||||
fn dialog_save (&self) -> Option<Dialog> {
|
||||
Some(Dialog::Save(Default::default()))
|
||||
Some(Dialog::Browser(BrowserTarget::SaveProject, Default::default()))
|
||||
}
|
||||
fn dialog_load (&self) -> Option<Dialog> {
|
||||
Some(Dialog::Load(Default::default()))
|
||||
Some(Dialog::Browser(BrowserTarget::LoadProject, Default::default()))
|
||||
}
|
||||
fn dialog_import_clip (&self) -> Option<Dialog> {
|
||||
Some(Dialog::Browser(BrowserTarget::ImportClip(Default::default()), Default::default()))
|
||||
}
|
||||
fn dialog_export_clip (&self) -> Option<Dialog> {
|
||||
Some(Dialog::Browser(BrowserTarget::ExportClip(Default::default()), Default::default()))
|
||||
}
|
||||
fn dialog_import_sample (&self) -> Option<Dialog> {
|
||||
Some(Dialog::Browser(BrowserTarget::ImportSample(Default::default()), Default::default()))
|
||||
}
|
||||
fn dialog_export_sample (&self) -> Option<Dialog> {
|
||||
Some(Dialog::Browser(BrowserTarget::ExportSample(Default::default()), Default::default()))
|
||||
}
|
||||
fn dialog_options (&self) -> Option<Dialog> {
|
||||
Some(Dialog::Options)
|
||||
|
|
|
|||
|
|
@ -64,18 +64,19 @@ impl App {
|
|||
}
|
||||
pub fn view_ports_status (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
self.project.get_track().map(|track|Bsp::s(
|
||||
Fixed::y(4.max(track.sequencer.midi_ins.len() as u16), Align::n(Map::south(1,
|
||||
Fixed::y(2.max(track.sequencer.midi_ins.len() as u16), Align::n(Map::south(1,
|
||||
||track.sequencer.midi_ins.iter(),
|
||||
|port, index|Fixed::x(20, FieldV(
|
||||
self.color,
|
||||
format!("IN {index}: "),
|
||||
format!("MIDI in {index}: "),
|
||||
format!("{}", port.name())))))),
|
||||
Fixed::y(4.max(track.sequencer.midi_outs.len() as u16), Align::n(Map::south(1,
|
||||
Fixed::y(2.max(track.sequencer.midi_outs.len() as u16), Align::n(Map::south(1,
|
||||
||track.sequencer.midi_outs.iter(),
|
||||
|port, index|Fixed::x(20, FieldV(
|
||||
self.color,
|
||||
format!("OUT {index}: "),
|
||||
format!("{}", port.name()))))))))
|
||||
format!("MIDI out {index}:"),
|
||||
format!("{}", port.name()))))))
|
||||
))
|
||||
}
|
||||
pub fn view_arranger (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
ArrangerView::new(&self.project, self.editor.as_ref())
|
||||
|
|
@ -116,10 +117,8 @@ impl App {
|
|||
self.view_dialog_menu().boxed(),
|
||||
Dialog::Help(offset) =>
|
||||
self.view_dialog_help(*offset).boxed(),
|
||||
Dialog::Save(browser) =>
|
||||
self.view_dialog_save(browser).boxed(),
|
||||
Dialog::Load(browser) =>
|
||||
self.view_dialog_load(browser).boxed(),
|
||||
Dialog::Browser(target, browser) =>
|
||||
self.view_dialog_browser(target, browser).boxed(),
|
||||
Dialog::Options =>
|
||||
self.view_dialog_options().boxed(),
|
||||
Dialog::Device(index) =>
|
||||
|
|
@ -162,11 +161,19 @@ impl App {
|
|||
pub fn view_dialog_message <'a> (&'a self, message: &'a Message) -> impl Content<TuiOut> + use<'a> {
|
||||
Bsp::s(message, Bsp::s("", "[ OK ]"))
|
||||
}
|
||||
pub fn view_dialog_save <'a> (&'a self, browser: &'a Browser) -> impl Content<TuiOut> + use<'a> {
|
||||
pub fn view_dialog_browser <'a> (&'a self, target: &BrowserTarget, browser: &'a Browser) -> impl Content<TuiOut> + use<'a> {
|
||||
Bsp::s(
|
||||
Fill::x(Align::w(Margin::xy(1, 1, Bsp::e(
|
||||
Tui::bold(true, " Save project: "),
|
||||
Shrink::x(3, Fixed::y(1, RepeatH("🭻"))))))),
|
||||
Padding::xy(3, 1, Fill::x(Align::w(FieldV(
|
||||
self.color,
|
||||
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)))
|
||||
}
|
||||
|
|
@ -178,6 +185,22 @@ impl App {
|
|||
Outer(true, Style::default().fg(Tui::g(96)))
|
||||
.enclose(Fill::xy(browser)))
|
||||
}
|
||||
pub fn view_dialog_export <'a> (&'a self, browser: &'a Browser) -> impl Content<TuiOut> + use<'a> {
|
||||
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)))
|
||||
}
|
||||
pub fn view_dialog_import <'a> (&'a self, browser: &'a Browser) -> impl Content<TuiOut> + use<'a> {
|
||||
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_dialog_options <'a> (&'a self) -> impl Content<TuiOut> + use<'a> {
|
||||
"TODO"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -246,9 +246,9 @@ fn draw_info_v (sample: Option<&Arc<RwLock<Sample>>>) -> impl Content<TuiOut> +
|
|||
Fill::x(Align::w(FieldH(theme, "Gain ", format!("{}", sample.gain)))),
|
||||
))
|
||||
}), Thunk::new(move||Tui::fg(Red, col!(
|
||||
"× No sample.",
|
||||
"Press record",
|
||||
"or import.",
|
||||
Tui::bold(true, "× No sample."),
|
||||
"[r] record",
|
||||
"[Shift-F9] import",
|
||||
))))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue