mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-01-31 08:36:40 +01:00
fix: compiles/runs (emptily)
This commit is contained in:
parent
211b433b3a
commit
b1074bd831
1 changed files with 63 additions and 65 deletions
128
app/tek.rs
128
app/tek.rs
|
|
@ -41,6 +41,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
pub mod model {
|
pub mod model {
|
||||||
|
use super::{*, gui::*};
|
||||||
/// Total state
|
/// Total state
|
||||||
#[derive(Default, Debug)] pub struct App {
|
#[derive(Default, Debug)] pub struct App {
|
||||||
/// Base color.
|
/// Base color.
|
||||||
|
|
@ -110,34 +111,39 @@ pub mod model {
|
||||||
/// Input bindings are only returned if this evaluates to true
|
/// Input bindings are only returned if this evaluates to true
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Condition(
|
pub struct Condition(
|
||||||
Arc<Box<dyn Fn()->bool + Send + Sync>>
|
pub Arc<Box<dyn Fn()->bool + Send + Sync>>
|
||||||
);
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
|
||||||
pub enum Axis { X, Y, Z, I }
|
|
||||||
/// Various possible dialog modes.
|
|
||||||
#[derive(Debug, Clone, Default, PartialEq)] pub enum Dialog {
|
|
||||||
#[default] None,
|
|
||||||
Help(usize),
|
|
||||||
Menu(usize, MenuItems),
|
|
||||||
Device(usize),
|
|
||||||
Message(Arc<str>),
|
|
||||||
Browse(BrowseTarget, Arc<Browse>),
|
|
||||||
Options,
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, Default, PartialEq)] pub struct MenuItems(
|
|
||||||
pub Arc<[MenuItem]>
|
|
||||||
);
|
|
||||||
#[derive(Clone)] pub struct MenuItem(
|
|
||||||
/// Label
|
|
||||||
pub Arc<str>,
|
|
||||||
/// Callback
|
|
||||||
pub Arc<Box<dyn Fn(&mut App)->Usually<()> + Send + Sync>>
|
|
||||||
);
|
);
|
||||||
|
def_command!(AppCommand: |app: App| {
|
||||||
|
Nop => Ok(None),
|
||||||
|
Confirm => Ok(match &app.dialog {
|
||||||
|
Dialog::Menu(index, items) => {
|
||||||
|
let callback = items.0[*index].1.clone();
|
||||||
|
callback(app)?;
|
||||||
|
None
|
||||||
|
},
|
||||||
|
_ => todo!(),
|
||||||
|
}),
|
||||||
|
Cancel => todo!(), // TODO delegate:
|
||||||
|
Inc { axis: Axis } => Ok(match (&app.dialog, axis) {
|
||||||
|
(Dialog::None, _) => todo!(),
|
||||||
|
(Dialog::Menu(_, _), Axis::Y) => AppCommand::SetDialog { dialog: app.dialog.menu_next() }
|
||||||
|
.execute(app)?,
|
||||||
|
_ => todo!()
|
||||||
|
}),
|
||||||
|
Dec { axis: Axis } => Ok(match (&app.dialog, axis) {
|
||||||
|
(Dialog::None, _) => None,
|
||||||
|
(Dialog::Menu(_, _), Axis::Y) => AppCommand::SetDialog { dialog: app.dialog.menu_prev() }
|
||||||
|
.execute(app)?,
|
||||||
|
_ => todo!()
|
||||||
|
}),
|
||||||
|
SetDialog { dialog: Dialog } => {
|
||||||
|
swap_value(&mut app.dialog, dialog, |dialog|Self::SetDialog { dialog })
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod core {
|
pub mod core {
|
||||||
use super::{*, model::*};
|
use super::{*, model::*, gui::*};
|
||||||
impl App {
|
impl App {
|
||||||
pub fn update_clock (&self) {
|
pub fn update_clock (&self) {
|
||||||
ViewCache::update_clock(&self.project.clock.view_cache, self.clock(), self.size.w() > 80)
|
ViewCache::update_clock(&self.project.clock.view_cache, self.clock(), self.size.w() > 80)
|
||||||
|
|
@ -389,10 +395,9 @@ pub mod core {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub mod ns {
|
pub mod ns {
|
||||||
|
use super::{*, model::*, gui::*};
|
||||||
// Allow source to be read as Literal string
|
// Allow source to be read as Literal string
|
||||||
dsl_ns!(App: Arc<str> {
|
dsl_ns!(App: Arc<str> { literal = |dsl|Ok(dsl.src()?.map(|x|x.into())); });
|
||||||
literal = |dsl|Ok(dsl.src()?.map(|x|x.into()));
|
|
||||||
});
|
|
||||||
// Provide boolean values.
|
// Provide boolean values.
|
||||||
dsl_ns!(App: bool {
|
dsl_ns!(App: bool {
|
||||||
// TODO literal = ...
|
// TODO literal = ...
|
||||||
|
|
@ -406,14 +411,10 @@ pub mod ns {
|
||||||
":focused/pool/export" => matches!(app.pool.mode, Some(PoolMode::Export(..))),
|
":focused/pool/export" => matches!(app.pool.mode, Some(PoolMode::Export(..))),
|
||||||
":focused/pool/rename" => matches!(app.pool.mode, Some(PoolMode::Rename(..))),
|
":focused/pool/rename" => matches!(app.pool.mode, Some(PoolMode::Rename(..))),
|
||||||
":focused/pool/length" => matches!(app.pool.mode, Some(PoolMode::Length(..))),
|
":focused/pool/length" => matches!(app.pool.mode, Some(PoolMode::Length(..))),
|
||||||
":focused/clip" => !app.editor_focused() && matches!(app.selection(),
|
":focused/clip" => !app.editor_focused() && matches!(app.selection(), Selection::TrackClip{..}),
|
||||||
Selection::TrackClip{..}),
|
":focused/track" => !app.editor_focused() && matches!(app.selection(), Selection::Track(..)),
|
||||||
":focused/track" => !app.editor_focused() && matches!(app.selection(),
|
":focused/scene" => !app.editor_focused() && matches!(app.selection(), Selection::Scene(..)),
|
||||||
Selection::Track(..)),
|
":focused/mix" => !app.editor_focused() && matches!(app.selection(), Selection::Mix),
|
||||||
":focused/scene" => !app.editor_focused() && matches!(app.selection(),
|
|
||||||
Selection::Scene(..)),
|
|
||||||
":focused/mix" => !app.editor_focused() && matches!(app.selection(),
|
|
||||||
Selection::Mix),
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
// TODO: provide colors here
|
// TODO: provide colors here
|
||||||
|
|
@ -533,36 +534,9 @@ pub mod ns {
|
||||||
"cancel" => AppCommand::Cancel,
|
"cancel" => AppCommand::Cancel,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
def_command!(AppCommand: |app: App| {
|
|
||||||
Nop => Ok(None),
|
|
||||||
Confirm => Ok(match &app.dialog {
|
|
||||||
Dialog::Menu(index, items) => {
|
|
||||||
let callback = items.0[*index].1.clone();
|
|
||||||
callback(app)?;
|
|
||||||
None
|
|
||||||
},
|
|
||||||
_ => todo!(),
|
|
||||||
}),
|
|
||||||
Cancel => todo!(), // TODO delegate:
|
|
||||||
Inc { axis: Axis } => Ok(match (&app.dialog, axis) {
|
|
||||||
(Dialog::None, _) => todo!(),
|
|
||||||
(Dialog::Menu(_, _), Axis::Y) => AppCommand::SetDialog { dialog: app.dialog.menu_next() }
|
|
||||||
.execute(app)?,
|
|
||||||
_ => todo!()
|
|
||||||
}),
|
|
||||||
Dec { axis: Axis } => Ok(match (&app.dialog, axis) {
|
|
||||||
(Dialog::None, _) => None,
|
|
||||||
(Dialog::Menu(_, _), Axis::Y) => AppCommand::SetDialog { dialog: app.dialog.menu_prev() }
|
|
||||||
.execute(app)?,
|
|
||||||
_ => todo!()
|
|
||||||
}),
|
|
||||||
SetDialog { dialog: Dialog } => {
|
|
||||||
swap_value(&mut app.dialog, dialog, |dialog|Self::SetDialog { dialog })
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
pub mod tui {
|
pub mod tui {
|
||||||
use super::{*, model::*};
|
use super::{*, model::*, gui::*};
|
||||||
handle!(TuiIn: |self: App, input|{
|
handle!(TuiIn: |self: App, input|{
|
||||||
let mut commands = vec![];
|
let mut commands = vec![];
|
||||||
for id in self.mode.keys.iter() {
|
for id in self.mode.keys.iter() {
|
||||||
|
|
@ -731,6 +705,28 @@ pub mod tui {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub mod gui {
|
pub mod gui {
|
||||||
|
use super::{*, model::*};
|
||||||
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
pub enum Axis { X, Y, Z, I }
|
||||||
|
/// Various possible dialog modes.
|
||||||
|
#[derive(Debug, Clone, Default, PartialEq)] pub enum Dialog {
|
||||||
|
#[default] None,
|
||||||
|
Help(usize),
|
||||||
|
Menu(usize, MenuItems),
|
||||||
|
Device(usize),
|
||||||
|
Message(Arc<str>),
|
||||||
|
Browse(BrowseTarget, Arc<Browse>),
|
||||||
|
Options,
|
||||||
|
}
|
||||||
|
#[derive(Debug, Clone, Default, PartialEq)] pub struct MenuItems(
|
||||||
|
pub Arc<[MenuItem]>
|
||||||
|
);
|
||||||
|
#[derive(Clone)] pub struct MenuItem(
|
||||||
|
/// Label
|
||||||
|
pub Arc<str>,
|
||||||
|
/// Callback
|
||||||
|
pub Arc<Box<dyn Fn(&mut App)->Usually<()> + Send + Sync>>
|
||||||
|
);
|
||||||
impl Dialog {
|
impl Dialog {
|
||||||
pub fn welcome () -> Self {
|
pub fn welcome () -> Self {
|
||||||
Self::Menu(1, MenuItems([
|
Self::Menu(1, MenuItems([
|
||||||
|
|
@ -764,6 +760,7 @@ pub mod gui {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub mod audio {
|
pub mod audio {
|
||||||
|
use super::{*, model::*};
|
||||||
audio!(
|
audio!(
|
||||||
|self: App, client, scope|{
|
|self: App, client, scope|{
|
||||||
let t0 = self.perf.get_t0();
|
let t0 = self.perf.get_t0();
|
||||||
|
|
@ -813,7 +810,7 @@ pub mod audio {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
pub mod glue {
|
pub mod glue {
|
||||||
use super::{*, model::*};
|
use super::{*, model::*, gui::*};
|
||||||
has!(Jack<'static>: |self: App|self.jack);
|
has!(Jack<'static>: |self: App|self.jack);
|
||||||
has!(Pool: |self: App|self.pool);
|
has!(Pool: |self: App|self.pool);
|
||||||
has!(Dialog: |self: App|self.dialog);
|
has!(Dialog: |self: App|self.dialog);
|
||||||
|
|
@ -850,7 +847,7 @@ pub mod glue {
|
||||||
}
|
}
|
||||||
/// Command-line configuration.
|
/// Command-line configuration.
|
||||||
#[cfg(feature = "cli")] pub mod cli {
|
#[cfg(feature = "cli")] pub mod cli {
|
||||||
use super::{*, model::*};
|
use super::{*, model::*, gui::*};
|
||||||
use clap::{self, Parser, Subcommand};
|
use clap::{self, Parser, Subcommand};
|
||||||
/// CLI banner.
|
/// CLI banner.
|
||||||
const HEADER: &'static str = r#"
|
const HEADER: &'static str = r#"
|
||||||
|
|
@ -973,6 +970,7 @@ pub mod glue {
|
||||||
}
|
}
|
||||||
/// Command-line entrypoint.
|
/// Command-line entrypoint.
|
||||||
#[cfg(feature = "cli")] pub fn main () -> Usually<()> {
|
#[cfg(feature = "cli")] pub fn main () -> Usually<()> {
|
||||||
|
use clap::Parser;
|
||||||
crate::cli::Cli::parse().run()
|
crate::cli::Cli::parse().run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue