mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
simplify
This commit is contained in:
parent
d7bbc2a412
commit
e3a3962130
15 changed files with 74 additions and 81 deletions
|
|
@ -18,8 +18,8 @@ handle!(TuiIn: |self: App, input|Ok(if let Some(command) = self.config.keys.comm
|
|||
}));
|
||||
|
||||
#[tengri_proc::command(App)] impl AppCommand {
|
||||
fn toggle_dialog (app: &mut App, dialog: Dialog) -> Perhaps<Self> {
|
||||
app.toggle_dialog(Some(dialog));
|
||||
fn dialog (app: &mut App, dialog: Option<Dialog>) -> Perhaps<Self> {
|
||||
app.toggle_dialog(dialog);
|
||||
Ok(None)
|
||||
}
|
||||
fn cancel_dialog (app: &mut App) -> Perhaps<Self> {
|
||||
|
|
|
|||
|
|
@ -16,12 +16,9 @@
|
|||
#![feature(type_changing_struct_update)]
|
||||
#![feature(let_chains)]
|
||||
#![feature(closure_lifetime_binder)]
|
||||
/// Standard result type.
|
||||
pub type Usually<T> = std::result::Result<T, Box<dyn std::error::Error>>;
|
||||
/// Standard optional result type.
|
||||
pub type Perhaps<T> = std::result::Result<Option<T>, Box<dyn std::error::Error>>;
|
||||
pub use ::tek_engine:: *;
|
||||
pub use ::tek_device::{self, *};
|
||||
pub use ::tengri::{Usually, Perhaps, Has};
|
||||
pub use ::tengri::dsl::*;
|
||||
pub use ::tengri::input::*;
|
||||
pub use ::tengri::output::*;
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ has!(Vec<JackMidiIn>: |self: App|self.project.midi_ins);
|
|||
has!(Vec<JackMidiOut>: |self: App|self.project.midi_outs);
|
||||
has!(Vec<Scene>: |self: App|self.project.scenes);
|
||||
has!(Vec<Track>: |self: App|self.project.tracks);
|
||||
has!(Measure<TuiOut>: |self: App|self.size);
|
||||
|
||||
has_size!(<TuiOut>|self: App|&self.size);
|
||||
has_clips!(|self: App|self.project.pool.clips);
|
||||
has_editor!(|self: App|{
|
||||
editor = self.editor;
|
||||
|
|
@ -152,8 +152,8 @@ impl App {
|
|||
/// Various possible dialog overlays
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum Dialog {
|
||||
Help,
|
||||
Menu,
|
||||
Help(usize),
|
||||
Menu(usize),
|
||||
Device(usize),
|
||||
Message(Message),
|
||||
Save(Browser),
|
||||
|
|
@ -216,29 +216,32 @@ impl App {
|
|||
fn focus_pool_length (&self) -> bool {
|
||||
matches!(self.project.pool.mode, Some(PoolMode::Length(..)))
|
||||
}
|
||||
fn dialog_device (&self) -> Dialog {
|
||||
Dialog::Device(0) // TODO
|
||||
fn dialog_none (&self) -> Option<Dialog> {
|
||||
None
|
||||
}
|
||||
fn dialog_device_prev (&self) -> Dialog {
|
||||
Dialog::Device(0) // TODO
|
||||
fn dialog_device (&self) -> Option<Dialog> {
|
||||
Some(Dialog::Device(0)) // TODO
|
||||
}
|
||||
fn dialog_device_next (&self) -> Dialog {
|
||||
Dialog::Device(0) // TODO
|
||||
fn dialog_device_prev (&self) -> Option<Dialog> {
|
||||
Some(Dialog::Device(0)) // TODO
|
||||
}
|
||||
fn dialog_help (&self) -> Dialog {
|
||||
Dialog::Help
|
||||
fn dialog_device_next (&self) -> Option<Dialog> {
|
||||
Some(Dialog::Device(0)) // TODO
|
||||
}
|
||||
fn dialog_menu (&self) -> Dialog {
|
||||
Dialog::Menu
|
||||
fn dialog_help (&self) -> Option<Dialog> {
|
||||
Some(Dialog::Help(0))
|
||||
}
|
||||
fn dialog_save (&self) -> Dialog {
|
||||
Dialog::Save(Default::default())
|
||||
fn dialog_menu (&self) -> Option<Dialog> {
|
||||
Some(Dialog::Menu(0))
|
||||
}
|
||||
fn dialog_load (&self) -> Dialog {
|
||||
Dialog::Load(Default::default())
|
||||
fn dialog_save (&self) -> Option<Dialog> {
|
||||
Some(Dialog::Save(Default::default()))
|
||||
}
|
||||
fn dialog_options (&self) -> Dialog {
|
||||
Dialog::Options
|
||||
fn dialog_load (&self) -> Option<Dialog> {
|
||||
Some(Dialog::Load(Default::default()))
|
||||
}
|
||||
fn dialog_options (&self) -> Option<Dialog> {
|
||||
Some(Dialog::Options)
|
||||
}
|
||||
fn editor_pitch (&self) -> Option<u7> {
|
||||
Some((self.editor().as_ref().map(|e|e.get_note_pos()).unwrap() as u8).into())
|
||||
|
|
|
|||
|
|
@ -58,10 +58,10 @@ impl App {
|
|||
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(self.dialog.as_ref().map(|dialog|match dialog {
|
||||
Dialog::Menu =>
|
||||
Dialog::Menu(_) =>
|
||||
self.view_dialog_menu().boxed(),
|
||||
Dialog::Help =>
|
||||
self.view_dialog_help().boxed(),
|
||||
Dialog::Help(offset) =>
|
||||
self.view_dialog_help(*offset).boxed(),
|
||||
Dialog::Save(browser) =>
|
||||
self.view_dialog_save().boxed(),
|
||||
Dialog::Load(browser) =>
|
||||
|
|
@ -84,12 +84,13 @@ impl App {
|
|||
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)))
|
||||
}
|
||||
pub fn view_dialog_help <'a> (&'a self) -> impl Content<TuiOut> + use<'a> {
|
||||
pub fn view_dialog_help <'a> (&'a self, offset: usize) -> impl Content<TuiOut> + use<'a> {
|
||||
Bsp::s(Tui::bold(true, "Help"), Bsp::s("", Map::south(1,
|
||||
||self.config.keys.layers.iter()
|
||||
move||self.config.keys.layers.iter()
|
||||
.filter_map(|a|(a.0)(self).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))))),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue