From 87cd6099ad2c0bf40c883ac2a6046ea54a580f92 Mon Sep 17 00:00:00 2001 From: unspeaker Date: Fri, 9 May 2025 17:28:09 +0300 Subject: [PATCH] rename: tek, Tek -> app, App --- crates/app/src/api.rs | 194 +++++++++++++++--------------- crates/app/src/audio.rs | 4 +- crates/app/src/config.rs | 4 +- crates/app/src/lib.rs | 28 ++--- crates/app/src/model.rs | 14 +-- crates/app/src/model/dialog.rs | 2 +- crates/app/src/model/scene.rs | 2 +- crates/app/src/model/selection.rs | 2 +- crates/app/src/model/track.rs | 2 +- crates/app/src/view.rs | 16 +-- crates/cli/tek.rs | 10 +- 11 files changed, 139 insertions(+), 139 deletions(-) diff --git a/crates/app/src/api.rs b/crates/app/src/api.rs index aa33ef34..8f25f108 100644 --- a/crates/app/src/api.rs +++ b/crates/app/src/api.rs @@ -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_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)?; if let Some(undo) = undo { self.history.push(undo); @@ -17,7 +17,7 @@ handle!(TuiIn: |self: Tek, input|Ok(if let Some(command) = self.config.keys.comm None })); -#[tengri_proc::expose] impl Tek { +#[tengri_proc::expose] impl App { fn focus_editor (&self) -> bool { 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 { - fn toggle_help (tek: &mut Tek, value: bool) -> Perhaps { - tek.toggle_dialog(Some(Dialog::Help)); +#[tengri_proc::command(App)] impl AppCommand { + fn toggle_help (app: &mut App, value: bool) -> Perhaps { + app.toggle_dialog(Some(Dialog::Help)); Ok(None) } - fn toggle_menu (tek: &mut Tek, value: bool) -> Perhaps { - tek.toggle_dialog(Some(Dialog::Menu)); + fn toggle_menu (app: &mut App, value: bool) -> Perhaps { + app.toggle_dialog(Some(Dialog::Menu)); Ok(None) } - fn toggle_edit (tek: &mut Tek, value: bool) -> Perhaps { - tek.toggle_editor(Some(value)); + fn toggle_edit (app: &mut App, value: bool) -> Perhaps { + app.toggle_editor(Some(value)); Ok(None) } - fn editor (tek: &mut Tek, command: MidiEditCommand) -> Perhaps { - Ok(tek.editor.as_mut().map(|editor|command.execute(editor)) + fn editor (app: &mut App, command: MidiEditCommand) -> Perhaps { + Ok(app.editor.as_mut().map(|editor|command.execute(editor)) .transpose()? .flatten() .map(|undo|Self::Editor { command: undo })) } - fn pool (tek: &mut Tek, command: PoolCommand) -> Perhaps { - Ok(if let Some(pool) = tek.pool.as_mut() { - let undo = command.clone().delegate(pool, |command|TekCommand::Pool{command})?; + fn pool (app: &mut App, command: PoolCommand) -> Perhaps { + Ok(if let Some(pool) = app.pool.as_mut() { + let undo = command.clone().delegate(pool, |command|AppCommand::Pool{command})?; // 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 PoolCommand::Select { .. } | // 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 }) } - fn sampler (tek: &mut Tek, command: SamplerCommand) -> Perhaps { - Ok(tek.sampler_mut() + fn sampler (app: &mut App, command: SamplerCommand) -> Perhaps { + Ok(app.sampler_mut() .map(|s|command.delegate(s, |command|Self::Sampler{command})) .transpose()? .flatten()) } - fn scene (tek: &mut Tek, command: SceneCommand) -> Perhaps { - Ok(command.delegate(tek, |command|Self::Scene{command})?) + fn scene (app: &mut App, command: SceneCommand) -> Perhaps { + Ok(command.delegate(app, |command|Self::Scene{command})?) } - fn track (tek: &mut Tek, command: TrackCommand) -> Perhaps { - Ok(command.delegate(tek, |command|Self::Track{command})?) + fn track (app: &mut App, command: TrackCommand) -> Perhaps { + Ok(command.delegate(app, |command|Self::Track{command})?) } - fn input (tek: &mut Tek, command: InputCommand) -> Perhaps { - Ok(command.delegate(tek, |command|Self::Input{command})?) + fn input (app: &mut App, command: InputCommand) -> Perhaps { + Ok(command.delegate(app, |command|Self::Input{command})?) } - fn output (tek: &mut Tek, command: OutputCommand) -> Perhaps { - Ok(command.delegate(tek, |command|Self::Output{command})?) + fn output (app: &mut App, command: OutputCommand) -> Perhaps { + Ok(command.delegate(app, |command|Self::Output{command})?) } - fn clip (tek: &mut Tek, command: ClipCommand) -> Perhaps { - Ok(command.delegate(tek, |command|Self::Clip{command})?) + fn clip (app: &mut App, command: ClipCommand) -> Perhaps { + Ok(command.delegate(app, |command|Self::Clip{command})?) } - fn clock (tek: &mut Tek, command: ClockCommand) -> Perhaps { - Ok(command.execute(&mut tek.clock)?.map(|command|Self::Clock{command})) + fn clock (app: &mut App, command: ClockCommand) -> Perhaps { + Ok(command.execute(&mut app.clock)?.map(|command|Self::Clock{command})) } - fn device (tek: &mut Tek, command: DeviceCommand) -> Perhaps { - Ok(command.delegate(tek, |command|Self::Device{command})?) + fn device (app: &mut App, command: DeviceCommand) -> Perhaps { + Ok(command.delegate(app, |command|Self::Device{command})?) } - fn message (tek: &mut Tek, command: MessageCommand) -> Perhaps { - Ok(command.delegate(tek, |command|Self::Message{command})?) + fn message (app: &mut App, command: MessageCommand) -> Perhaps { + Ok(command.delegate(app, |command|Self::Message{command})?) } - fn color (tek: &mut Tek, theme: ItemTheme) -> Perhaps { - Ok(tek.set_color(Some(theme)).map(|theme|Self::Color{theme})) + fn color (app: &mut App, theme: ItemTheme) -> Perhaps { + Ok(app.set_color(Some(theme)).map(|theme|Self::Color{theme})) } - fn enqueue (tek: &mut Tek, clip: Option>>) -> Perhaps { + fn enqueue (app: &mut App, clip: Option>>) -> Perhaps { todo!() } - fn history (tek: &mut Tek, delta: isize) -> Perhaps { + fn history (app: &mut App, delta: isize) -> Perhaps { todo!() } - fn zoom (tek: &mut Tek, zoom: usize) -> Perhaps { + fn zoom (app: &mut App, zoom: usize) -> Perhaps { todo!() } - fn launch (tek: &mut Tek) -> Perhaps { - tek.launch(); + fn launch (app: &mut App) -> Perhaps { + app.launch(); Ok(None) } - fn select (tek: &mut Tek, selection: Selection) -> Perhaps { - tek.select(selection); + fn select (app: &mut App, selection: Selection) -> Perhaps { + app.select(selection); Ok(None) //("select" [t: usize, s: usize] Some(match (t.expect("no track"), s.expect("no scene")) { //(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)), //(t, s) => Self::Select(Selection::TrackClip { track: t, scene: s }) }))) } - fn stop_all (tek: &mut Tek) -> Perhaps { - tek.stop_all(); + fn stop_all (app: &mut App) -> Perhaps { + app.stop_all(); Ok(None) } } -#[tengri_proc::command(Tek)] impl InputCommand { - fn add (tek: &mut Tek) -> Perhaps { - tek.midi_in_add()?; +#[tengri_proc::command(App)] impl InputCommand { + fn add (app: &mut App) -> Perhaps { + app.midi_in_add()?; Ok(None) } } -#[tengri_proc::command(Tek)] impl OutputCommand { - fn add (tek: &mut Tek) -> Perhaps { - tek.midi_out_add()?; +#[tengri_proc::command(App)] impl OutputCommand { + fn add (app: &mut App) -> Perhaps { + app.midi_out_add()?; Ok(None) } } -#[tengri_proc::command(Tek)] impl DeviceCommand { - fn picker (tek: &mut Tek) -> Perhaps { - tek.device_picker_show(); +#[tengri_proc::command(App)] impl DeviceCommand { + fn picker (app: &mut App) -> Perhaps { + app.device_picker_show(); Ok(None) } - fn pick (tek: &mut Tek, i: usize) -> Perhaps { - tek.device_pick(i); + fn pick (app: &mut App, i: usize) -> Perhaps { + app.device_pick(i); Ok(None) } - fn add (tek: &mut Tek, i: usize) -> Perhaps { - tek.device_add(i); + fn add (app: &mut App, i: usize) -> Perhaps { + app.device_add(i); Ok(None) } } -#[tengri_proc::command(Tek)] impl MessageCommand { - fn dismiss (tek: &mut Tek) -> Perhaps { - tek.message_dismiss(); +#[tengri_proc::command(App)] impl MessageCommand { + fn dismiss (app: &mut App) -> Perhaps { + app.message_dismiss(); Ok(None) } } -#[tengri_proc::command(Tek)] impl TrackCommand { - fn toggle_play (tek: &mut Tek) -> Perhaps { +#[tengri_proc::command(App)] impl TrackCommand { + fn toggle_play (app: &mut App) -> Perhaps { todo!() } - fn toggle_solo (tek: &mut Tek) -> Perhaps { + fn toggle_solo (app: &mut App) -> Perhaps { todo!() } - fn toggle_rec (tek: &mut Tek) -> Perhaps { - tek.track_toggle_record(); + fn toggle_rec (app: &mut App) -> Perhaps { + app.track_toggle_record(); Ok(Some(Self::ToggleRec)) } - fn toggle_mon (tek: &mut Tek) -> Perhaps { - tek.track_toggle_monitor(); + fn toggle_mon (app: &mut App) -> Perhaps { + app.track_toggle_monitor(); Ok(Some(Self::ToggleMon)) } - fn set_size (tek: &mut Tek, size: usize) -> Perhaps { + fn set_size (app: &mut App, size: usize) -> Perhaps { todo!() } - fn set_zoom (tek: &mut Tek, zoom: usize) -> Perhaps { + fn set_zoom (app: &mut App, zoom: usize) -> Perhaps { todo!() } - fn swap (tek: &mut Tek, index: usize, other: usize) -> Perhaps { + fn swap (app: &mut App, index: usize, other: usize) -> Perhaps { todo!(); Ok(Some(Self::Swap { index, other })) } - fn del (tek: &mut Tek, index: usize) -> Perhaps { - tek.track_del(index); + fn del (app: &mut App, index: usize) -> Perhaps { + app.track_del(index); Ok(None) } - fn stop (tek: &mut Tek, index: usize) -> Perhaps { - tek.tracks[index].player.enqueue_next(None); + fn stop (app: &mut App, index: usize) -> Perhaps { + app.tracks[index].player.enqueue_next(None); Ok(None) } - fn add (tek: &mut Tek) -> Perhaps { - Ok(Some(Self::Del { index: tek.track_add_focus()? })) + fn add (app: &mut App) -> Perhaps { + Ok(Some(Self::Del { index: app.track_add_focus()? })) } - fn set_color (tek: &mut Tek, index: usize, color: ItemTheme) -> Perhaps { - Ok(Some(Self::SetColor { index, color: tek.track_set_color(index, color) })) + fn set_color (app: &mut App, index: usize, color: ItemTheme) -> Perhaps { + Ok(Some(Self::SetColor { index, color: app.track_set_color(index, color) })) } } -#[tengri_proc::command(Tek)] impl SceneCommand { - fn add (tek: &mut Tek) -> Perhaps { +#[tengri_proc::command(App)] impl SceneCommand { + fn add (app: &mut App) -> Perhaps { todo!() } - fn del (tek: &mut Tek, index: usize) -> Perhaps { - tek.scene_del(index); + fn del (app: &mut App, index: usize) -> Perhaps { + app.scene_del(index); Ok(None) } - fn enqueue (tek: &mut Tek, index: usize) -> Perhaps { - tek.scene_enqueue(index); + fn enqueue (app: &mut App, index: usize) -> Perhaps { + app.scene_enqueue(index); Ok(None) } - fn set_color (tek: &mut Tek, index: usize, color: ItemTheme) -> Perhaps { - Ok(Some(Self::SetColor { index, color: tek.scene_set_color(index, color) })) + fn set_color (app: &mut App, index: usize, color: ItemTheme) -> Perhaps { + Ok(Some(Self::SetColor { index, color: app.scene_set_color(index, color) })) } - fn set_size (tek: &mut Tek, index: usize, size: usize) -> Perhaps { + fn set_size (app: &mut App, index: usize, size: usize) -> Perhaps { todo!() } - fn set_zoom (tek: &mut Tek, index: usize, zoom: usize) -> Perhaps { + fn set_zoom (app: &mut App, index: usize, zoom: usize) -> Perhaps { todo!() } - fn swap (tek: &mut Tek, index: usize, other: usize) -> Perhaps { + fn swap (app: &mut App, index: usize, other: usize) -> Perhaps { todo!(); Ok(Some(Self::Swap { index, other })) } } -#[tengri_proc::command(Tek)] impl ClipCommand { - fn get (tek: &mut Tek, a: usize, b: usize) -> Perhaps { +#[tengri_proc::command(App)] impl ClipCommand { + fn get (app: &mut App, a: usize, b: usize) -> Perhaps { //(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()))) todo!() } - fn edit (tek: &mut Tek, a: usize, b: usize) -> Perhaps { + fn edit (app: &mut App, a: usize, b: usize) -> Perhaps { //(Edit [clip: MaybeClip] cmd_todo!("\n\rtodo: clip: edit: {clip:?}")) //("edit" [a: MaybeClip] Some(Self::Edit(a.unwrap()))) todo!() } - fn set_loop (tek: &mut Tek, a: usize, b: usize) -> Perhaps { + fn set_loop (app: &mut App, a: usize, b: usize) -> Perhaps { //(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()))) todo!() } - fn put (tek: &mut Tek, a: usize, b: usize) -> Perhaps { + fn put (app: &mut App, a: usize, b: usize) -> Perhaps { //(Put [t: usize, s: usize, c: MaybeClip] //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()))) todo!() } - fn del (tek: &mut Tek, a: usize, b: usize) -> Perhaps { + fn del (app: &mut App, a: usize, b: usize) -> Perhaps { //("delete" [a: usize, b: usize] Some(Self::Put(a.unwrap(), b.unwrap(), None)))) todo!() } - fn enqueue (tek: &mut Tek, a: usize, b: usize) -> Perhaps { + fn enqueue (app: &mut App, a: usize, b: usize) -> Perhaps { //(Enqueue [t: usize, s: usize] //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()))) todo!() } - fn set_color (tek: &mut Tek, a: usize, b: usize) -> Perhaps { + fn set_color (app: &mut App, a: usize, b: usize) -> Perhaps { //(SetColor [t: usize, s: usize, c: ItemTheme] //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()))) diff --git a/crates/app/src/audio.rs b/crates/app/src/audio.rs index 6d42c36d..5bdf1ffc 100644 --- a/crates/app/src/audio.rs +++ b/crates/app/src/audio.rs @@ -1,7 +1,7 @@ use crate::*; -impl HasJack for Tek { fn jack (&self) -> &Jack { &self.jack } } +impl HasJack for App { fn jack (&self) -> &Jack { &self.jack } } audio!( - |self: Tek, client, scope|{ + |self: App, client, scope|{ // Start profiling cycle let t0 = self.perf.get_t0(); // Update transport clock diff --git a/crates/app/src/config.rs b/crates/app/src/config.rs index 2875e0cc..fc996811 100644 --- a/crates/app/src/config.rs +++ b/crates/app/src/config.rs @@ -13,7 +13,7 @@ pub struct Configuration { /// View definition pub view: TokenIter<'static>, // Input keymap - pub keys: InputMap<'static, Tek, TekCommand, TuiIn, TokenIter<'static>> + pub keys: InputMap<'static, App, AppCommand, TuiIn, TokenIter<'static>> } impl Configuration { @@ -87,7 +87,7 @@ impl Configuration { } fn parse_keys (base: &impl AsRef, iter: Option>) - -> Usually>> + -> Usually>> { if iter.is_none() { return Err(format!("missing keys definition").into()) diff --git a/crates/app/src/lib.rs b/crates/app/src/lib.rs index fef8fb56..c83d835b 100644 --- a/crates/app/src/lib.rs +++ b/crates/app/src/lib.rs @@ -43,13 +43,13 @@ mod model; pub use self::model::*; mod view; pub use self::view::*; #[cfg(test)] #[test] fn test_model () { - let mut tek = Tek::default(); - let _ = tek.clip(); - let _ = tek.toggle_loop(); + let mut app = App::default(); + let _ = app.clip(); + let _ = app.toggle_loop(); } #[cfg(test)] #[test] fn test_model_scene () { - let mut app = Tek::default(); + let mut app = App::default(); let _ = app.scene_longest(); let _ = app.scene(); let _ = app.scene_mut(); @@ -62,7 +62,7 @@ mod view; pub use self::view::*; #[cfg(test)] #[test] fn test_view_clock () { let _ = button_play_pause(true); - let mut app = Tek::default(); + let mut app = App::default(); let _ = app.view_transport(); let _ = app.view_status(); let _ = app.update_clock(); @@ -101,18 +101,18 @@ mod view; pub use self::view::*; } #[cfg(test)] #[test] fn test_view_iter () { - let mut tek = Tek::default(); - tek.editor = Some(Default::default()); - let _: Vec<_> = tek.inputs_with_sizes().collect(); - let _: Vec<_> = tek.outputs_with_sizes().collect(); - let _: Vec<_> = tek.tracks_with_sizes().collect(); - let _: Vec<_> = tek.scenes_with_sizes(true, 10, 10).collect(); - //let _: Vec<_> = tek.scenes_with_colors(true, 10).collect(); - //let _: Vec<_> = tek.scenes_with_track_colors(true, 10, 10).collect(); + let mut app = App::default(); + app.editor = Some(Default::default()); + let _: Vec<_> = app.inputs_with_sizes().collect(); + let _: Vec<_> = app.outputs_with_sizes().collect(); + let _: Vec<_> = app.tracks_with_sizes().collect(); + let _: Vec<_> = app.scenes_with_sizes(true, 10, 10).collect(); + //let _: Vec<_> = app.scenes_with_colors(true, 10).collect(); + //let _: Vec<_> = app.scenes_with_track_colors(true, 10, 10).collect(); } #[cfg(test)] #[test] fn test_view_sizes () { - let app = Tek::default(); + let app = App::default(); let _ = app.w(); let _ = app.w_sidebar(); let _ = app.w_tracks_area(); diff --git a/crates/app/src/model.rs b/crates/app/src/model.rs index 660e0cff..a18943f4 100644 --- a/crates/app/src/model.rs +++ b/crates/app/src/model.rs @@ -8,7 +8,7 @@ mod track; pub use self::track::*; mod scene; pub use self::scene::*; #[derive(Default, Debug)] -pub struct Tek { +pub struct App { /// Must not be dropped for the duration of the process pub jack: Jack, /// Source of time @@ -52,7 +52,7 @@ pub struct Tek { /// Whether in edit mode pub editing: AtomicBool, /// Undo history - pub history: Vec, + pub history: Vec, /// Port handles pub ports: std::collections::BTreeMap>, // Cache of formatted strings @@ -63,7 +63,7 @@ pub struct Tek { pub config: Configuration } -impl Tek { +impl App { /// Add multiple tracks pub fn tracks_add ( @@ -441,13 +441,13 @@ impl Tek { } } -has_size!(|self: Tek|&self.size); +has_size!(|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_w = { let size = self.size.w(); diff --git a/crates/app/src/model/dialog.rs b/crates/app/src/model/dialog.rs index 092025b9..5b0313dd 100644 --- a/crates/app/src/model/dialog.rs +++ b/crates/app/src/model/dialog.rs @@ -1,6 +1,6 @@ use crate::*; -impl Tek { +impl App { pub fn toggle_dialog (&mut self, dialog: Option) { self.dialog = if self.dialog == dialog { None diff --git a/crates/app/src/model/scene.rs b/crates/app/src/model/scene.rs index dc501600..5159eeb0 100644 --- a/crates/app/src/model/scene.rs +++ b/crates/app/src/model/scene.rs @@ -67,7 +67,7 @@ pub trait HasScenes: HasSelection + HasEditor + Send + Sync { } } -impl HasScenes for Tek { +impl HasScenes for App { fn scenes (&self) -> &Vec { &self.scenes } fn scenes_mut (&mut self) -> &mut Vec { &mut self.scenes } } diff --git a/crates/app/src/model/selection.rs b/crates/app/src/model/selection.rs index 4f2141e3..82d588cc 100644 --- a/crates/app/src/model/selection.rs +++ b/crates/app/src/model/selection.rs @@ -141,7 +141,7 @@ impl Selection { } } -impl HasSelection for Tek { +impl HasSelection for App { fn selected (&self) -> &Selection { &self.selected } fn selected_mut (&mut self) -> &mut Selection { &mut self.selected } } diff --git a/crates/app/src/model/track.rs b/crates/app/src/model/track.rs index dc194c1e..5fa9d941 100644 --- a/crates/app/src/model/track.rs +++ b/crates/app/src/model/track.rs @@ -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 { &self.midi_ins } fn midi_outs (&self) -> &Vec { &self.midi_outs } fn tracks (&self) -> &Vec { &self.tracks } diff --git a/crates/app/src/view.rs b/crates/app/src/view.rs index 2f1bfdd9..22bf3d02 100644 --- a/crates/app/src/view.rs +++ b/crates/app/src/view.rs @@ -3,7 +3,7 @@ pub(crate) use std::fmt::Write; pub(crate) use ::tengri::tui::ratatui::prelude::Position; #[tengri_proc::view(TuiOut)] -impl Tek { +impl App { fn view_nil (&self) -> impl Content + use<'_> { "nil" } @@ -58,7 +58,7 @@ impl Tek { } } -impl Tek { +impl App { fn view_dialog_menu (&self) -> impl Content { let options = ||["Projects", "Settings", "Help", "Quit"].iter(); 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)|{ let width = if Some(index) == active.copied() { bigger } else { track.width.max(8) }; let data = (index, track, x, x + width); - x += width + Tek::TRACK_SPACING; + x += width + App::TRACK_SPACING; data }) } @@ -180,7 +180,7 @@ impl Tek { } pub(crate) struct ArrangerView<'a> { - app: &'a Tek, + app: &'a App, is_editing: bool, @@ -222,7 +222,7 @@ impl<'a> Content for ArrangerView<'a> { } impl<'a> ArrangerView<'a> { - pub fn new (app: &'a Tek) -> Self { + pub fn new (app: &'a App) -> Self { Self { app, is_editing: app.is_editing(), @@ -436,7 +436,7 @@ impl<'a> ArrangerView<'a> { let Self { width, width_side, width_mid, scenes_height, scene_last, scene_selected, - track_selected, is_editing, app: Tek { editor, .. }, .. + track_selected, is_editing, app: App { editor, .. }, .. } = self; 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) -> 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 { None } else { @@ -545,7 +545,7 @@ impl<'a> ArrangerView<'a> { pub(crate) fn scenes_with_track_colors (&self, track: usize) -> 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 { None } else { diff --git a/crates/cli/tek.rs b/crates/cli/tek.rs index a5990ad0..ff5baa49 100644 --- a/crates/cli/tek.rs +++ b/crates/cli/tek.rs @@ -110,7 +110,7 @@ impl Cli { _ => todo!("{mode:?}"), }; let config = Configuration::new(&config_path, false)?; - let mut app = Tek { + let mut app = App { jack: jack.clone(), color: ItemTheme::random(), clock: Clock::new(jack, self.bpm)?, @@ -181,8 +181,8 @@ const HEADER: &'static str = r#" Cli::command().debug_assert(); let jack = Jack::default(); //TODO: - //let _ = Tek::new_clock(&jack, None, false, false, &[], &[]); - //let _ = Tek::new_sequencer(&jack, None, false, false, &[], &[]); - //let _ = Tek::new_groovebox(&jack, None, false, false, &[], &[], &[&[], &[]], &[&[], &[]]); - //let _ = Tek::new_arranger(&jack, None, false, false, &[], &[], &[&[], &[]], &[&[], &[]], 0, 0, 0); + //let _ = App::new_clock(&jack, None, false, false, &[], &[]); + //let _ = App::new_sequencer(&jack, None, false, false, &[], &[]); + //let _ = App::new_groovebox(&jack, None, false, false, &[], &[], &[&[], &[]], &[&[], &[]]); + //let _ = App::new_arranger(&jack, None, false, false, &[], &[], &[&[], &[]], &[&[], &[]], 0, 0, 0); }