rename: tek, Tek -> app, App
Some checks are pending
/ build (push) Waiting to run

This commit is contained in:
🪞👃🪞 2025-05-09 17:28:09 +03:00
parent cc88743054
commit 87cd6099ad
11 changed files with 139 additions and 139 deletions

View file

@ -7,7 +7,7 @@ macro_rules! ns { ($C:ty, $s:expr, $a:expr, $W:expr) => { <$C>::try_from_expr($s
macro_rules! cmd { ($cmd:expr) => {{ $cmd; None }}; } macro_rules! cmd { ($cmd:expr) => {{ $cmd; None }}; }
macro_rules! cmd_todo { ($msg:literal) => {{ println!($msg); None }}; } macro_rules! cmd_todo { ($msg:literal) => {{ println!($msg); None }}; }
handle!(TuiIn: |self: Tek, input|Ok(if let Some(command) = self.config.keys.command(self, input) { handle!(TuiIn: |self: App, input|Ok(if let Some(command) = self.config.keys.command(self, input) {
let undo = command.execute(self)?; let undo = command.execute(self)?;
if let Some(undo) = undo { if let Some(undo) = undo {
self.history.push(undo); self.history.push(undo);
@ -17,7 +17,7 @@ handle!(TuiIn: |self: Tek, input|Ok(if let Some(command) = self.config.keys.comm
None None
})); }));
#[tengri_proc::expose] impl Tek { #[tengri_proc::expose] impl App {
fn focus_editor (&self) -> bool { fn focus_editor (&self) -> bool {
self.is_editing() self.is_editing()
} }
@ -253,30 +253,30 @@ handle!(TuiIn: |self: Tek, input|Ok(if let Some(command) = self.config.keys.comm
} }
} }
#[tengri_proc::command(Tek)] impl TekCommand { #[tengri_proc::command(App)] impl AppCommand {
fn toggle_help (tek: &mut Tek, value: bool) -> Perhaps<Self> { fn toggle_help (app: &mut App, value: bool) -> Perhaps<Self> {
tek.toggle_dialog(Some(Dialog::Help)); app.toggle_dialog(Some(Dialog::Help));
Ok(None) Ok(None)
} }
fn toggle_menu (tek: &mut Tek, value: bool) -> Perhaps<Self> { fn toggle_menu (app: &mut App, value: bool) -> Perhaps<Self> {
tek.toggle_dialog(Some(Dialog::Menu)); app.toggle_dialog(Some(Dialog::Menu));
Ok(None) Ok(None)
} }
fn toggle_edit (tek: &mut Tek, value: bool) -> Perhaps<Self> { fn toggle_edit (app: &mut App, value: bool) -> Perhaps<Self> {
tek.toggle_editor(Some(value)); app.toggle_editor(Some(value));
Ok(None) Ok(None)
} }
fn editor (tek: &mut Tek, command: MidiEditCommand) -> Perhaps<Self> { fn editor (app: &mut App, command: MidiEditCommand) -> Perhaps<Self> {
Ok(tek.editor.as_mut().map(|editor|command.execute(editor)) Ok(app.editor.as_mut().map(|editor|command.execute(editor))
.transpose()? .transpose()?
.flatten() .flatten()
.map(|undo|Self::Editor { command: undo })) .map(|undo|Self::Editor { command: undo }))
} }
fn pool (tek: &mut Tek, command: PoolCommand) -> Perhaps<Self> { fn pool (app: &mut App, command: PoolCommand) -> Perhaps<Self> {
Ok(if let Some(pool) = tek.pool.as_mut() { Ok(if let Some(pool) = app.pool.as_mut() {
let undo = command.clone().delegate(pool, |command|TekCommand::Pool{command})?; let undo = command.clone().delegate(pool, |command|AppCommand::Pool{command})?;
// update linked editor after pool action // update linked editor after pool action
tek.editor.as_mut().map(|editor|match command { app.editor.as_mut().map(|editor|match command {
// autoselect: automatically load selected clip in editor // autoselect: automatically load selected clip in editor
PoolCommand::Select { .. } | PoolCommand::Select { .. } |
// autocolor: update color in all places simultaneously // autocolor: update color in all places simultaneously
@ -289,54 +289,54 @@ handle!(TuiIn: |self: Tek, input|Ok(if let Some(command) = self.config.keys.comm
None None
}) })
} }
fn sampler (tek: &mut Tek, command: SamplerCommand) -> Perhaps<Self> { fn sampler (app: &mut App, command: SamplerCommand) -> Perhaps<Self> {
Ok(tek.sampler_mut() Ok(app.sampler_mut()
.map(|s|command.delegate(s, |command|Self::Sampler{command})) .map(|s|command.delegate(s, |command|Self::Sampler{command}))
.transpose()? .transpose()?
.flatten()) .flatten())
} }
fn scene (tek: &mut Tek, command: SceneCommand) -> Perhaps<Self> { fn scene (app: &mut App, command: SceneCommand) -> Perhaps<Self> {
Ok(command.delegate(tek, |command|Self::Scene{command})?) Ok(command.delegate(app, |command|Self::Scene{command})?)
} }
fn track (tek: &mut Tek, command: TrackCommand) -> Perhaps<Self> { fn track (app: &mut App, command: TrackCommand) -> Perhaps<Self> {
Ok(command.delegate(tek, |command|Self::Track{command})?) Ok(command.delegate(app, |command|Self::Track{command})?)
} }
fn input (tek: &mut Tek, command: InputCommand) -> Perhaps<Self> { fn input (app: &mut App, command: InputCommand) -> Perhaps<Self> {
Ok(command.delegate(tek, |command|Self::Input{command})?) Ok(command.delegate(app, |command|Self::Input{command})?)
} }
fn output (tek: &mut Tek, command: OutputCommand) -> Perhaps<Self> { fn output (app: &mut App, command: OutputCommand) -> Perhaps<Self> {
Ok(command.delegate(tek, |command|Self::Output{command})?) Ok(command.delegate(app, |command|Self::Output{command})?)
} }
fn clip (tek: &mut Tek, command: ClipCommand) -> Perhaps<Self> { fn clip (app: &mut App, command: ClipCommand) -> Perhaps<Self> {
Ok(command.delegate(tek, |command|Self::Clip{command})?) Ok(command.delegate(app, |command|Self::Clip{command})?)
} }
fn clock (tek: &mut Tek, command: ClockCommand) -> Perhaps<Self> { fn clock (app: &mut App, command: ClockCommand) -> Perhaps<Self> {
Ok(command.execute(&mut tek.clock)?.map(|command|Self::Clock{command})) Ok(command.execute(&mut app.clock)?.map(|command|Self::Clock{command}))
} }
fn device (tek: &mut Tek, command: DeviceCommand) -> Perhaps<Self> { fn device (app: &mut App, command: DeviceCommand) -> Perhaps<Self> {
Ok(command.delegate(tek, |command|Self::Device{command})?) Ok(command.delegate(app, |command|Self::Device{command})?)
} }
fn message (tek: &mut Tek, command: MessageCommand) -> Perhaps<Self> { fn message (app: &mut App, command: MessageCommand) -> Perhaps<Self> {
Ok(command.delegate(tek, |command|Self::Message{command})?) Ok(command.delegate(app, |command|Self::Message{command})?)
} }
fn color (tek: &mut Tek, theme: ItemTheme) -> Perhaps<Self> { fn color (app: &mut App, theme: ItemTheme) -> Perhaps<Self> {
Ok(tek.set_color(Some(theme)).map(|theme|Self::Color{theme})) Ok(app.set_color(Some(theme)).map(|theme|Self::Color{theme}))
} }
fn enqueue (tek: &mut Tek, clip: Option<Arc<RwLock<MidiClip>>>) -> Perhaps<Self> { fn enqueue (app: &mut App, clip: Option<Arc<RwLock<MidiClip>>>) -> Perhaps<Self> {
todo!() todo!()
} }
fn history (tek: &mut Tek, delta: isize) -> Perhaps<Self> { fn history (app: &mut App, delta: isize) -> Perhaps<Self> {
todo!() todo!()
} }
fn zoom (tek: &mut Tek, zoom: usize) -> Perhaps<Self> { fn zoom (app: &mut App, zoom: usize) -> Perhaps<Self> {
todo!() todo!()
} }
fn launch (tek: &mut Tek) -> Perhaps<Self> { fn launch (app: &mut App) -> Perhaps<Self> {
tek.launch(); app.launch();
Ok(None) Ok(None)
} }
fn select (tek: &mut Tek, selection: Selection) -> Perhaps<Self> { fn select (app: &mut App, selection: Selection) -> Perhaps<Self> {
tek.select(selection); app.select(selection);
Ok(None) Ok(None)
//("select" [t: usize, s: usize] Some(match (t.expect("no track"), s.expect("no scene")) { //("select" [t: usize, s: usize] Some(match (t.expect("no track"), s.expect("no scene")) {
//(0, 0) => Self::Select(Selection::Mix), //(0, 0) => Self::Select(Selection::Mix),
@ -344,149 +344,149 @@ handle!(TuiIn: |self: Tek, input|Ok(if let Some(command) = self.config.keys.comm
//(0, s) => Self::Select(Selection::Scene(s)), //(0, s) => Self::Select(Selection::Scene(s)),
//(t, s) => Self::Select(Selection::TrackClip { track: t, scene: s }) }))) //(t, s) => Self::Select(Selection::TrackClip { track: t, scene: s }) })))
} }
fn stop_all (tek: &mut Tek) -> Perhaps<Self> { fn stop_all (app: &mut App) -> Perhaps<Self> {
tek.stop_all(); app.stop_all();
Ok(None) Ok(None)
} }
} }
#[tengri_proc::command(Tek)] impl InputCommand { #[tengri_proc::command(App)] impl InputCommand {
fn add (tek: &mut Tek) -> Perhaps<Self> { fn add (app: &mut App) -> Perhaps<Self> {
tek.midi_in_add()?; app.midi_in_add()?;
Ok(None) Ok(None)
} }
} }
#[tengri_proc::command(Tek)] impl OutputCommand { #[tengri_proc::command(App)] impl OutputCommand {
fn add (tek: &mut Tek) -> Perhaps<Self> { fn add (app: &mut App) -> Perhaps<Self> {
tek.midi_out_add()?; app.midi_out_add()?;
Ok(None) Ok(None)
} }
} }
#[tengri_proc::command(Tek)] impl DeviceCommand { #[tengri_proc::command(App)] impl DeviceCommand {
fn picker (tek: &mut Tek) -> Perhaps<Self> { fn picker (app: &mut App) -> Perhaps<Self> {
tek.device_picker_show(); app.device_picker_show();
Ok(None) Ok(None)
} }
fn pick (tek: &mut Tek, i: usize) -> Perhaps<Self> { fn pick (app: &mut App, i: usize) -> Perhaps<Self> {
tek.device_pick(i); app.device_pick(i);
Ok(None) Ok(None)
} }
fn add (tek: &mut Tek, i: usize) -> Perhaps<Self> { fn add (app: &mut App, i: usize) -> Perhaps<Self> {
tek.device_add(i); app.device_add(i);
Ok(None) Ok(None)
} }
} }
#[tengri_proc::command(Tek)] impl MessageCommand { #[tengri_proc::command(App)] impl MessageCommand {
fn dismiss (tek: &mut Tek) -> Perhaps<Self> { fn dismiss (app: &mut App) -> Perhaps<Self> {
tek.message_dismiss(); app.message_dismiss();
Ok(None) Ok(None)
} }
} }
#[tengri_proc::command(Tek)] impl TrackCommand { #[tengri_proc::command(App)] impl TrackCommand {
fn toggle_play (tek: &mut Tek) -> Perhaps<Self> { fn toggle_play (app: &mut App) -> Perhaps<Self> {
todo!() todo!()
} }
fn toggle_solo (tek: &mut Tek) -> Perhaps<Self> { fn toggle_solo (app: &mut App) -> Perhaps<Self> {
todo!() todo!()
} }
fn toggle_rec (tek: &mut Tek) -> Perhaps<Self> { fn toggle_rec (app: &mut App) -> Perhaps<Self> {
tek.track_toggle_record(); app.track_toggle_record();
Ok(Some(Self::ToggleRec)) Ok(Some(Self::ToggleRec))
} }
fn toggle_mon (tek: &mut Tek) -> Perhaps<Self> { fn toggle_mon (app: &mut App) -> Perhaps<Self> {
tek.track_toggle_monitor(); app.track_toggle_monitor();
Ok(Some(Self::ToggleMon)) Ok(Some(Self::ToggleMon))
} }
fn set_size (tek: &mut Tek, size: usize) -> Perhaps<Self> { fn set_size (app: &mut App, size: usize) -> Perhaps<Self> {
todo!() todo!()
} }
fn set_zoom (tek: &mut Tek, zoom: usize) -> Perhaps<Self> { fn set_zoom (app: &mut App, zoom: usize) -> Perhaps<Self> {
todo!() todo!()
} }
fn swap (tek: &mut Tek, index: usize, other: usize) -> Perhaps<Self> { fn swap (app: &mut App, index: usize, other: usize) -> Perhaps<Self> {
todo!(); todo!();
Ok(Some(Self::Swap { index, other })) Ok(Some(Self::Swap { index, other }))
} }
fn del (tek: &mut Tek, index: usize) -> Perhaps<Self> { fn del (app: &mut App, index: usize) -> Perhaps<Self> {
tek.track_del(index); app.track_del(index);
Ok(None) Ok(None)
} }
fn stop (tek: &mut Tek, index: usize) -> Perhaps<Self> { fn stop (app: &mut App, index: usize) -> Perhaps<Self> {
tek.tracks[index].player.enqueue_next(None); app.tracks[index].player.enqueue_next(None);
Ok(None) Ok(None)
} }
fn add (tek: &mut Tek) -> Perhaps<Self> { fn add (app: &mut App) -> Perhaps<Self> {
Ok(Some(Self::Del { index: tek.track_add_focus()? })) Ok(Some(Self::Del { index: app.track_add_focus()? }))
} }
fn set_color (tek: &mut Tek, index: usize, color: ItemTheme) -> Perhaps<Self> { fn set_color (app: &mut App, index: usize, color: ItemTheme) -> Perhaps<Self> {
Ok(Some(Self::SetColor { index, color: tek.track_set_color(index, color) })) Ok(Some(Self::SetColor { index, color: app.track_set_color(index, color) }))
} }
} }
#[tengri_proc::command(Tek)] impl SceneCommand { #[tengri_proc::command(App)] impl SceneCommand {
fn add (tek: &mut Tek) -> Perhaps<Self> { fn add (app: &mut App) -> Perhaps<Self> {
todo!() todo!()
} }
fn del (tek: &mut Tek, index: usize) -> Perhaps<Self> { fn del (app: &mut App, index: usize) -> Perhaps<Self> {
tek.scene_del(index); app.scene_del(index);
Ok(None) Ok(None)
} }
fn enqueue (tek: &mut Tek, index: usize) -> Perhaps<Self> { fn enqueue (app: &mut App, index: usize) -> Perhaps<Self> {
tek.scene_enqueue(index); app.scene_enqueue(index);
Ok(None) Ok(None)
} }
fn set_color (tek: &mut Tek, index: usize, color: ItemTheme) -> Perhaps<Self> { fn set_color (app: &mut App, index: usize, color: ItemTheme) -> Perhaps<Self> {
Ok(Some(Self::SetColor { index, color: tek.scene_set_color(index, color) })) Ok(Some(Self::SetColor { index, color: app.scene_set_color(index, color) }))
} }
fn set_size (tek: &mut Tek, index: usize, size: usize) -> Perhaps<Self> { fn set_size (app: &mut App, index: usize, size: usize) -> Perhaps<Self> {
todo!() todo!()
} }
fn set_zoom (tek: &mut Tek, index: usize, zoom: usize) -> Perhaps<Self> { fn set_zoom (app: &mut App, index: usize, zoom: usize) -> Perhaps<Self> {
todo!() todo!()
} }
fn swap (tek: &mut Tek, index: usize, other: usize) -> Perhaps<Self> { fn swap (app: &mut App, index: usize, other: usize) -> Perhaps<Self> {
todo!(); todo!();
Ok(Some(Self::Swap { index, other })) Ok(Some(Self::Swap { index, other }))
} }
} }
#[tengri_proc::command(Tek)] impl ClipCommand { #[tengri_proc::command(App)] impl ClipCommand {
fn get (tek: &mut Tek, a: usize, b: usize) -> Perhaps<Self> { fn get (app: &mut App, a: usize, b: usize) -> Perhaps<Self> {
//(Get [a: usize, b: usize] cmd_todo!("\n\rtodo: clip: get: {a} {b}")) //(Get [a: usize, b: usize] cmd_todo!("\n\rtodo: clip: get: {a} {b}"))
//("get" [a: usize, b: usize] Some(Self::Get(a.unwrap(), b.unwrap()))) //("get" [a: usize, b: usize] Some(Self::Get(a.unwrap(), b.unwrap())))
todo!() todo!()
} }
fn edit (tek: &mut Tek, a: usize, b: usize) -> Perhaps<Self> { fn edit (app: &mut App, a: usize, b: usize) -> Perhaps<Self> {
//(Edit [clip: MaybeClip] cmd_todo!("\n\rtodo: clip: edit: {clip:?}")) //(Edit [clip: MaybeClip] cmd_todo!("\n\rtodo: clip: edit: {clip:?}"))
//("edit" [a: MaybeClip] Some(Self::Edit(a.unwrap()))) //("edit" [a: MaybeClip] Some(Self::Edit(a.unwrap())))
todo!() todo!()
} }
fn set_loop (tek: &mut Tek, a: usize, b: usize) -> Perhaps<Self> { fn set_loop (app: &mut App, a: usize, b: usize) -> Perhaps<Self> {
//(SetLoop [t: usize, s: usize, l: bool] cmd_todo!("\n\rtodo: {self:?}")) //(SetLoop [t: usize, s: usize, l: bool] cmd_todo!("\n\rtodo: {self:?}"))
//("loop" [a: usize, b: usize, c: bool] Some(Self::SetLoop(a.unwrap(), b.unwrap(), c.unwrap()))) //("loop" [a: usize, b: usize, c: bool] Some(Self::SetLoop(a.unwrap(), b.unwrap(), c.unwrap())))
todo!() todo!()
} }
fn put (tek: &mut Tek, a: usize, b: usize) -> Perhaps<Self> { fn put (app: &mut App, a: usize, b: usize) -> Perhaps<Self> {
//(Put [t: usize, s: usize, c: MaybeClip] //(Put [t: usize, s: usize, c: MaybeClip]
//Some(Self::Put(t, s, app.clip_put(t, s, c)))) //Some(Self::Put(t, s, app.clip_put(t, s, c))))
//("put" [a: usize, b: usize, c: MaybeClip] Some(Self::Put(a.unwrap(), b.unwrap(), c.unwrap()))) //("put" [a: usize, b: usize, c: MaybeClip] Some(Self::Put(a.unwrap(), b.unwrap(), c.unwrap())))
todo!() todo!()
} }
fn del (tek: &mut Tek, a: usize, b: usize) -> Perhaps<Self> { fn del (app: &mut App, a: usize, b: usize) -> Perhaps<Self> {
//("delete" [a: usize, b: usize] Some(Self::Put(a.unwrap(), b.unwrap(), None)))) //("delete" [a: usize, b: usize] Some(Self::Put(a.unwrap(), b.unwrap(), None))))
todo!() todo!()
} }
fn enqueue (tek: &mut Tek, a: usize, b: usize) -> Perhaps<Self> { fn enqueue (app: &mut App, a: usize, b: usize) -> Perhaps<Self> {
//(Enqueue [t: usize, s: usize] //(Enqueue [t: usize, s: usize]
//cmd!(app.tracks[t].player.enqueue_next(app.scenes[s].clips[t].as_ref()))) //cmd!(app.tracks[t].player.enqueue_next(app.scenes[s].clips[t].as_ref())))
//("enqueue" [a: usize, b: usize] Some(Self::Enqueue(a.unwrap(), b.unwrap()))) //("enqueue" [a: usize, b: usize] Some(Self::Enqueue(a.unwrap(), b.unwrap())))
todo!() todo!()
} }
fn set_color (tek: &mut Tek, a: usize, b: usize) -> Perhaps<Self> { fn set_color (app: &mut App, a: usize, b: usize) -> Perhaps<Self> {
//(SetColor [t: usize, s: usize, c: ItemTheme] //(SetColor [t: usize, s: usize, c: ItemTheme]
//app.clip_set_color(t, s, c).map(|o|Self::SetColor(t, s, o))))); //app.clip_set_color(t, s, c).map(|o|Self::SetColor(t, s, o)))));
//("color" [a: usize, b: usize] Some(Self::SetColor(a.unwrap(), b.unwrap(), ItemTheme::random()))) //("color" [a: usize, b: usize] Some(Self::SetColor(a.unwrap(), b.unwrap(), ItemTheme::random())))

View file

@ -1,7 +1,7 @@
use crate::*; use crate::*;
impl HasJack for Tek { fn jack (&self) -> &Jack { &self.jack } } impl HasJack for App { fn jack (&self) -> &Jack { &self.jack } }
audio!( audio!(
|self: Tek, client, scope|{ |self: App, client, scope|{
// Start profiling cycle // Start profiling cycle
let t0 = self.perf.get_t0(); let t0 = self.perf.get_t0();
// Update transport clock // Update transport clock

View file

@ -13,7 +13,7 @@ pub struct Configuration {
/// View definition /// View definition
pub view: TokenIter<'static>, pub view: TokenIter<'static>,
// Input keymap // Input keymap
pub keys: InputMap<'static, Tek, TekCommand, TuiIn, TokenIter<'static>> pub keys: InputMap<'static, App, AppCommand, TuiIn, TokenIter<'static>>
} }
impl Configuration { impl Configuration {
@ -87,7 +87,7 @@ impl Configuration {
} }
fn parse_keys (base: &impl AsRef<Path>, iter: Option<TokenIter<'static>>) fn parse_keys (base: &impl AsRef<Path>, iter: Option<TokenIter<'static>>)
-> Usually<InputMap<'static, Tek, TekCommand, TuiIn, TokenIter<'static>>> -> Usually<InputMap<'static, App, AppCommand, TuiIn, TokenIter<'static>>>
{ {
if iter.is_none() { if iter.is_none() {
return Err(format!("missing keys definition").into()) return Err(format!("missing keys definition").into())

View file

@ -43,13 +43,13 @@ mod model; pub use self::model::*;
mod view; pub use self::view::*; mod view; pub use self::view::*;
#[cfg(test)] #[test] fn test_model () { #[cfg(test)] #[test] fn test_model () {
let mut tek = Tek::default(); let mut app = App::default();
let _ = tek.clip(); let _ = app.clip();
let _ = tek.toggle_loop(); let _ = app.toggle_loop();
} }
#[cfg(test)] #[test] fn test_model_scene () { #[cfg(test)] #[test] fn test_model_scene () {
let mut app = Tek::default(); let mut app = App::default();
let _ = app.scene_longest(); let _ = app.scene_longest();
let _ = app.scene(); let _ = app.scene();
let _ = app.scene_mut(); let _ = app.scene_mut();
@ -62,7 +62,7 @@ mod view; pub use self::view::*;
#[cfg(test)] #[test] fn test_view_clock () { #[cfg(test)] #[test] fn test_view_clock () {
let _ = button_play_pause(true); let _ = button_play_pause(true);
let mut app = Tek::default(); let mut app = App::default();
let _ = app.view_transport(); let _ = app.view_transport();
let _ = app.view_status(); let _ = app.view_status();
let _ = app.update_clock(); let _ = app.update_clock();
@ -101,18 +101,18 @@ mod view; pub use self::view::*;
} }
#[cfg(test)] #[test] fn test_view_iter () { #[cfg(test)] #[test] fn test_view_iter () {
let mut tek = Tek::default(); let mut app = App::default();
tek.editor = Some(Default::default()); app.editor = Some(Default::default());
let _: Vec<_> = tek.inputs_with_sizes().collect(); let _: Vec<_> = app.inputs_with_sizes().collect();
let _: Vec<_> = tek.outputs_with_sizes().collect(); let _: Vec<_> = app.outputs_with_sizes().collect();
let _: Vec<_> = tek.tracks_with_sizes().collect(); let _: Vec<_> = app.tracks_with_sizes().collect();
let _: Vec<_> = tek.scenes_with_sizes(true, 10, 10).collect(); let _: Vec<_> = app.scenes_with_sizes(true, 10, 10).collect();
//let _: Vec<_> = tek.scenes_with_colors(true, 10).collect(); //let _: Vec<_> = app.scenes_with_colors(true, 10).collect();
//let _: Vec<_> = tek.scenes_with_track_colors(true, 10, 10).collect(); //let _: Vec<_> = app.scenes_with_track_colors(true, 10, 10).collect();
} }
#[cfg(test)] #[test] fn test_view_sizes () { #[cfg(test)] #[test] fn test_view_sizes () {
let app = Tek::default(); let app = App::default();
let _ = app.w(); let _ = app.w();
let _ = app.w_sidebar(); let _ = app.w_sidebar();
let _ = app.w_tracks_area(); let _ = app.w_tracks_area();

View file

@ -8,7 +8,7 @@ mod track; pub use self::track::*;
mod scene; pub use self::scene::*; mod scene; pub use self::scene::*;
#[derive(Default, Debug)] #[derive(Default, Debug)]
pub struct Tek { pub struct App {
/// Must not be dropped for the duration of the process /// Must not be dropped for the duration of the process
pub jack: Jack, pub jack: Jack,
/// Source of time /// Source of time
@ -52,7 +52,7 @@ pub struct Tek {
/// Whether in edit mode /// Whether in edit mode
pub editing: AtomicBool, pub editing: AtomicBool,
/// Undo history /// Undo history
pub history: Vec<TekCommand>, pub history: Vec<AppCommand>,
/// Port handles /// Port handles
pub ports: std::collections::BTreeMap<u32, Port<Unowned>>, pub ports: std::collections::BTreeMap<u32, Port<Unowned>>,
// Cache of formatted strings // Cache of formatted strings
@ -63,7 +63,7 @@ pub struct Tek {
pub config: Configuration pub config: Configuration
} }
impl Tek { impl App {
/// Add multiple tracks /// Add multiple tracks
pub fn tracks_add ( pub fn tracks_add (
@ -441,13 +441,13 @@ impl Tek {
} }
} }
has_size!(<TuiOut>|self: Tek|&self.size); has_size!(<TuiOut>|self: App|&self.size);
has_clock!(|self: Tek|self.clock); has_clock!(|self: App|self.clock);
has_clips!(|self: Tek|self.pool.as_ref().expect("no clip pool").clips); has_clips!(|self: App|self.pool.as_ref().expect("no clip pool").clips);
has_editor!(|self: Tek|{ has_editor!(|self: App|{
editor = self.editor; editor = self.editor;
editor_w = { editor_w = {
let size = self.size.w(); let size = self.size.w();

View file

@ -1,6 +1,6 @@
use crate::*; use crate::*;
impl Tek { impl App {
pub fn toggle_dialog (&mut self, dialog: Option<Dialog>) { pub fn toggle_dialog (&mut self, dialog: Option<Dialog>) {
self.dialog = if self.dialog == dialog { self.dialog = if self.dialog == dialog {
None None

View file

@ -67,7 +67,7 @@ pub trait HasScenes: HasSelection + HasEditor + Send + Sync {
} }
} }
impl HasScenes for Tek { impl HasScenes for App {
fn scenes (&self) -> &Vec<Scene> { &self.scenes } fn scenes (&self) -> &Vec<Scene> { &self.scenes }
fn scenes_mut (&mut self) -> &mut Vec<Scene> { &mut self.scenes } fn scenes_mut (&mut self) -> &mut Vec<Scene> { &mut self.scenes }
} }

View file

@ -141,7 +141,7 @@ impl Selection {
} }
} }
impl HasSelection for Tek { impl HasSelection for App {
fn selected (&self) -> &Selection { &self.selected } fn selected (&self) -> &Selection { &self.selected }
fn selected_mut (&mut self) -> &mut Selection { &mut self.selected } fn selected_mut (&mut self) -> &mut Selection { &mut self.selected }
} }

View file

@ -142,7 +142,7 @@ pub trait HasTracks: HasSelection + HasClock + HasJack + HasEditor + Send + Sync
} }
} }
impl HasTracks for Tek { impl HasTracks for App {
fn midi_ins (&self) -> &Vec<JackMidiIn> { &self.midi_ins } fn midi_ins (&self) -> &Vec<JackMidiIn> { &self.midi_ins }
fn midi_outs (&self) -> &Vec<JackMidiOut> { &self.midi_outs } fn midi_outs (&self) -> &Vec<JackMidiOut> { &self.midi_outs }
fn tracks (&self) -> &Vec<Track> { &self.tracks } fn tracks (&self) -> &Vec<Track> { &self.tracks }

View file

@ -3,7 +3,7 @@ pub(crate) use std::fmt::Write;
pub(crate) use ::tengri::tui::ratatui::prelude::Position; pub(crate) use ::tengri::tui::ratatui::prelude::Position;
#[tengri_proc::view(TuiOut)] #[tengri_proc::view(TuiOut)]
impl Tek { impl App {
fn view_nil (&self) -> impl Content<TuiOut> + use<'_> { fn view_nil (&self) -> impl Content<TuiOut> + use<'_> {
"nil" "nil"
} }
@ -58,7 +58,7 @@ impl Tek {
} }
} }
impl Tek { impl App {
fn view_dialog_menu (&self) -> impl Content<TuiOut> { fn view_dialog_menu (&self) -> impl Content<TuiOut> {
let options = ||["Projects", "Settings", "Help", "Quit"].iter(); let options = ||["Projects", "Settings", "Help", "Quit"].iter();
let option = |a,i|Tui::fg(Rgb(255,255,255), format!("{}", a)); let option = |a,i|Tui::fg(Rgb(255,255,255), format!("{}", a));
@ -148,7 +148,7 @@ impl Tek {
self.tracks().iter().enumerate().map(move |(index, track)|{ self.tracks().iter().enumerate().map(move |(index, track)|{
let width = if Some(index) == active.copied() { bigger } else { track.width.max(8) }; let width = if Some(index) == active.copied() { bigger } else { track.width.max(8) };
let data = (index, track, x, x + width); let data = (index, track, x, x + width);
x += width + Tek::TRACK_SPACING; x += width + App::TRACK_SPACING;
data data
}) })
} }
@ -180,7 +180,7 @@ impl Tek {
} }
pub(crate) struct ArrangerView<'a> { pub(crate) struct ArrangerView<'a> {
app: &'a Tek, app: &'a App,
is_editing: bool, is_editing: bool,
@ -222,7 +222,7 @@ impl<'a> Content<TuiOut> for ArrangerView<'a> {
} }
impl<'a> ArrangerView<'a> { impl<'a> ArrangerView<'a> {
pub fn new (app: &'a Tek) -> Self { pub fn new (app: &'a App) -> Self {
Self { Self {
app, app,
is_editing: app.is_editing(), is_editing: app.is_editing(),
@ -436,7 +436,7 @@ impl<'a> ArrangerView<'a> {
let Self { let Self {
width, width_side, width_mid, width, width_side, width_mid,
scenes_height, scene_last, scene_selected, scenes_height, scene_last, scene_selected,
track_selected, is_editing, app: Tek { editor, .. }, .. track_selected, is_editing, app: App { editor, .. }, ..
} = self; } = self;
let scene_headers = Map::new(||self.scenes_with_scene_colors(), let scene_headers = Map::new(||self.scenes_with_scene_colors(),
@ -530,7 +530,7 @@ impl<'a> ArrangerView<'a> {
pub(crate) fn scenes_with_scene_colors (&self) pub(crate) fn scenes_with_scene_colors (&self)
-> impl ScenesColors<'_> -> impl ScenesColors<'_>
{ {
self.app.scenes_with_sizes(self.is_editing, Tek::H_SCENE, Tek::H_EDITOR).map_while( self.app.scenes_with_sizes(self.is_editing, App::H_SCENE, App::H_EDITOR).map_while(
move|(s, scene, y1, y2)|if y2 as u16 > self.scenes_height { move|(s, scene, y1, y2)|if y2 as u16 > self.scenes_height {
None None
} else { } else {
@ -545,7 +545,7 @@ impl<'a> ArrangerView<'a> {
pub(crate) fn scenes_with_track_colors (&self, track: usize) pub(crate) fn scenes_with_track_colors (&self, track: usize)
-> impl ScenesColors<'_> -> impl ScenesColors<'_>
{ {
self.app.scenes_with_sizes(self.is_editing, Tek::H_SCENE, Tek::H_EDITOR).map_while( self.app.scenes_with_sizes(self.is_editing, App::H_SCENE, App::H_EDITOR).map_while(
move|(s, scene, y1, y2)|if y2 as u16 > self.scenes_height { move|(s, scene, y1, y2)|if y2 as u16 > self.scenes_height {
None None
} else { } else {

View file

@ -110,7 +110,7 @@ impl Cli {
_ => todo!("{mode:?}"), _ => todo!("{mode:?}"),
}; };
let config = Configuration::new(&config_path, false)?; let config = Configuration::new(&config_path, false)?;
let mut app = Tek { let mut app = App {
jack: jack.clone(), jack: jack.clone(),
color: ItemTheme::random(), color: ItemTheme::random(),
clock: Clock::new(jack, self.bpm)?, clock: Clock::new(jack, self.bpm)?,
@ -181,8 +181,8 @@ const HEADER: &'static str = r#"
Cli::command().debug_assert(); Cli::command().debug_assert();
let jack = Jack::default(); let jack = Jack::default();
//TODO: //TODO:
//let _ = Tek::new_clock(&jack, None, false, false, &[], &[]); //let _ = App::new_clock(&jack, None, false, false, &[], &[]);
//let _ = Tek::new_sequencer(&jack, None, false, false, &[], &[]); //let _ = App::new_sequencer(&jack, None, false, false, &[], &[]);
//let _ = Tek::new_groovebox(&jack, None, false, false, &[], &[], &[&[], &[]], &[&[], &[]]); //let _ = App::new_groovebox(&jack, None, false, false, &[], &[], &[&[], &[]], &[&[], &[]]);
//let _ = Tek::new_arranger(&jack, None, false, false, &[], &[], &[&[], &[]], &[&[], &[]], 0, 0, 0); //let _ = App::new_arranger(&jack, None, false, false, &[], &[], &[&[], &[]], &[&[], &[]], 0, 0, 0);
} }