mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
This commit is contained in:
parent
cc88743054
commit
87cd6099ad
11 changed files with 139 additions and 139 deletions
|
|
@ -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<Self> {
|
||||
tek.toggle_dialog(Some(Dialog::Help));
|
||||
#[tengri_proc::command(App)] impl AppCommand {
|
||||
fn toggle_help (app: &mut App, value: bool) -> Perhaps<Self> {
|
||||
app.toggle_dialog(Some(Dialog::Help));
|
||||
Ok(None)
|
||||
}
|
||||
fn toggle_menu (tek: &mut Tek, value: bool) -> Perhaps<Self> {
|
||||
tek.toggle_dialog(Some(Dialog::Menu));
|
||||
fn toggle_menu (app: &mut App, value: bool) -> Perhaps<Self> {
|
||||
app.toggle_dialog(Some(Dialog::Menu));
|
||||
Ok(None)
|
||||
}
|
||||
fn toggle_edit (tek: &mut Tek, value: bool) -> Perhaps<Self> {
|
||||
tek.toggle_editor(Some(value));
|
||||
fn toggle_edit (app: &mut App, value: bool) -> Perhaps<Self> {
|
||||
app.toggle_editor(Some(value));
|
||||
Ok(None)
|
||||
}
|
||||
fn editor (tek: &mut Tek, command: MidiEditCommand) -> Perhaps<Self> {
|
||||
Ok(tek.editor.as_mut().map(|editor|command.execute(editor))
|
||||
fn editor (app: &mut App, command: MidiEditCommand) -> Perhaps<Self> {
|
||||
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<Self> {
|
||||
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<Self> {
|
||||
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<Self> {
|
||||
Ok(tek.sampler_mut()
|
||||
fn sampler (app: &mut App, command: SamplerCommand) -> Perhaps<Self> {
|
||||
Ok(app.sampler_mut()
|
||||
.map(|s|command.delegate(s, |command|Self::Sampler{command}))
|
||||
.transpose()?
|
||||
.flatten())
|
||||
}
|
||||
fn scene (tek: &mut Tek, command: SceneCommand) -> Perhaps<Self> {
|
||||
Ok(command.delegate(tek, |command|Self::Scene{command})?)
|
||||
fn scene (app: &mut App, command: SceneCommand) -> Perhaps<Self> {
|
||||
Ok(command.delegate(app, |command|Self::Scene{command})?)
|
||||
}
|
||||
fn track (tek: &mut Tek, command: TrackCommand) -> Perhaps<Self> {
|
||||
Ok(command.delegate(tek, |command|Self::Track{command})?)
|
||||
fn track (app: &mut App, command: TrackCommand) -> Perhaps<Self> {
|
||||
Ok(command.delegate(app, |command|Self::Track{command})?)
|
||||
}
|
||||
fn input (tek: &mut Tek, command: InputCommand) -> Perhaps<Self> {
|
||||
Ok(command.delegate(tek, |command|Self::Input{command})?)
|
||||
fn input (app: &mut App, command: InputCommand) -> Perhaps<Self> {
|
||||
Ok(command.delegate(app, |command|Self::Input{command})?)
|
||||
}
|
||||
fn output (tek: &mut Tek, command: OutputCommand) -> Perhaps<Self> {
|
||||
Ok(command.delegate(tek, |command|Self::Output{command})?)
|
||||
fn output (app: &mut App, command: OutputCommand) -> Perhaps<Self> {
|
||||
Ok(command.delegate(app, |command|Self::Output{command})?)
|
||||
}
|
||||
fn clip (tek: &mut Tek, command: ClipCommand) -> Perhaps<Self> {
|
||||
Ok(command.delegate(tek, |command|Self::Clip{command})?)
|
||||
fn clip (app: &mut App, command: ClipCommand) -> Perhaps<Self> {
|
||||
Ok(command.delegate(app, |command|Self::Clip{command})?)
|
||||
}
|
||||
fn clock (tek: &mut Tek, command: ClockCommand) -> Perhaps<Self> {
|
||||
Ok(command.execute(&mut tek.clock)?.map(|command|Self::Clock{command}))
|
||||
fn clock (app: &mut App, command: ClockCommand) -> Perhaps<Self> {
|
||||
Ok(command.execute(&mut app.clock)?.map(|command|Self::Clock{command}))
|
||||
}
|
||||
fn device (tek: &mut Tek, command: DeviceCommand) -> Perhaps<Self> {
|
||||
Ok(command.delegate(tek, |command|Self::Device{command})?)
|
||||
fn device (app: &mut App, command: DeviceCommand) -> Perhaps<Self> {
|
||||
Ok(command.delegate(app, |command|Self::Device{command})?)
|
||||
}
|
||||
fn message (tek: &mut Tek, command: MessageCommand) -> Perhaps<Self> {
|
||||
Ok(command.delegate(tek, |command|Self::Message{command})?)
|
||||
fn message (app: &mut App, command: MessageCommand) -> Perhaps<Self> {
|
||||
Ok(command.delegate(app, |command|Self::Message{command})?)
|
||||
}
|
||||
fn color (tek: &mut Tek, theme: ItemTheme) -> Perhaps<Self> {
|
||||
Ok(tek.set_color(Some(theme)).map(|theme|Self::Color{theme}))
|
||||
fn color (app: &mut App, theme: ItemTheme) -> Perhaps<Self> {
|
||||
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!()
|
||||
}
|
||||
fn history (tek: &mut Tek, delta: isize) -> Perhaps<Self> {
|
||||
fn history (app: &mut App, delta: isize) -> Perhaps<Self> {
|
||||
todo!()
|
||||
}
|
||||
fn zoom (tek: &mut Tek, zoom: usize) -> Perhaps<Self> {
|
||||
fn zoom (app: &mut App, zoom: usize) -> Perhaps<Self> {
|
||||
todo!()
|
||||
}
|
||||
fn launch (tek: &mut Tek) -> Perhaps<Self> {
|
||||
tek.launch();
|
||||
fn launch (app: &mut App) -> Perhaps<Self> {
|
||||
app.launch();
|
||||
Ok(None)
|
||||
}
|
||||
fn select (tek: &mut Tek, selection: Selection) -> Perhaps<Self> {
|
||||
tek.select(selection);
|
||||
fn select (app: &mut App, selection: Selection) -> Perhaps<Self> {
|
||||
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<Self> {
|
||||
tek.stop_all();
|
||||
fn stop_all (app: &mut App) -> Perhaps<Self> {
|
||||
app.stop_all();
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
#[tengri_proc::command(Tek)] impl InputCommand {
|
||||
fn add (tek: &mut Tek) -> Perhaps<Self> {
|
||||
tek.midi_in_add()?;
|
||||
#[tengri_proc::command(App)] impl InputCommand {
|
||||
fn add (app: &mut App) -> Perhaps<Self> {
|
||||
app.midi_in_add()?;
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
#[tengri_proc::command(Tek)] impl OutputCommand {
|
||||
fn add (tek: &mut Tek) -> Perhaps<Self> {
|
||||
tek.midi_out_add()?;
|
||||
#[tengri_proc::command(App)] impl OutputCommand {
|
||||
fn add (app: &mut App) -> Perhaps<Self> {
|
||||
app.midi_out_add()?;
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
#[tengri_proc::command(Tek)] impl DeviceCommand {
|
||||
fn picker (tek: &mut Tek) -> Perhaps<Self> {
|
||||
tek.device_picker_show();
|
||||
#[tengri_proc::command(App)] impl DeviceCommand {
|
||||
fn picker (app: &mut App) -> Perhaps<Self> {
|
||||
app.device_picker_show();
|
||||
Ok(None)
|
||||
}
|
||||
fn pick (tek: &mut Tek, i: usize) -> Perhaps<Self> {
|
||||
tek.device_pick(i);
|
||||
fn pick (app: &mut App, i: usize) -> Perhaps<Self> {
|
||||
app.device_pick(i);
|
||||
Ok(None)
|
||||
}
|
||||
fn add (tek: &mut Tek, i: usize) -> Perhaps<Self> {
|
||||
tek.device_add(i);
|
||||
fn add (app: &mut App, i: usize) -> Perhaps<Self> {
|
||||
app.device_add(i);
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
#[tengri_proc::command(Tek)] impl MessageCommand {
|
||||
fn dismiss (tek: &mut Tek) -> Perhaps<Self> {
|
||||
tek.message_dismiss();
|
||||
#[tengri_proc::command(App)] impl MessageCommand {
|
||||
fn dismiss (app: &mut App) -> Perhaps<Self> {
|
||||
app.message_dismiss();
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
#[tengri_proc::command(Tek)] impl TrackCommand {
|
||||
fn toggle_play (tek: &mut Tek) -> Perhaps<Self> {
|
||||
#[tengri_proc::command(App)] impl TrackCommand {
|
||||
fn toggle_play (app: &mut App) -> Perhaps<Self> {
|
||||
todo!()
|
||||
}
|
||||
fn toggle_solo (tek: &mut Tek) -> Perhaps<Self> {
|
||||
fn toggle_solo (app: &mut App) -> Perhaps<Self> {
|
||||
todo!()
|
||||
}
|
||||
fn toggle_rec (tek: &mut Tek) -> Perhaps<Self> {
|
||||
tek.track_toggle_record();
|
||||
fn toggle_rec (app: &mut App) -> Perhaps<Self> {
|
||||
app.track_toggle_record();
|
||||
Ok(Some(Self::ToggleRec))
|
||||
}
|
||||
fn toggle_mon (tek: &mut Tek) -> Perhaps<Self> {
|
||||
tek.track_toggle_monitor();
|
||||
fn toggle_mon (app: &mut App) -> Perhaps<Self> {
|
||||
app.track_toggle_monitor();
|
||||
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!()
|
||||
}
|
||||
fn set_zoom (tek: &mut Tek, zoom: usize) -> Perhaps<Self> {
|
||||
fn set_zoom (app: &mut App, zoom: usize) -> Perhaps<Self> {
|
||||
todo!()
|
||||
}
|
||||
fn swap (tek: &mut Tek, index: usize, other: usize) -> Perhaps<Self> {
|
||||
fn swap (app: &mut App, index: usize, other: usize) -> Perhaps<Self> {
|
||||
todo!();
|
||||
Ok(Some(Self::Swap { index, other }))
|
||||
}
|
||||
fn del (tek: &mut Tek, index: usize) -> Perhaps<Self> {
|
||||
tek.track_del(index);
|
||||
fn del (app: &mut App, index: usize) -> Perhaps<Self> {
|
||||
app.track_del(index);
|
||||
Ok(None)
|
||||
}
|
||||
fn stop (tek: &mut Tek, index: usize) -> Perhaps<Self> {
|
||||
tek.tracks[index].player.enqueue_next(None);
|
||||
fn stop (app: &mut App, index: usize) -> Perhaps<Self> {
|
||||
app.tracks[index].player.enqueue_next(None);
|
||||
Ok(None)
|
||||
}
|
||||
fn add (tek: &mut Tek) -> Perhaps<Self> {
|
||||
Ok(Some(Self::Del { index: tek.track_add_focus()? }))
|
||||
fn add (app: &mut App) -> Perhaps<Self> {
|
||||
Ok(Some(Self::Del { index: app.track_add_focus()? }))
|
||||
}
|
||||
fn set_color (tek: &mut Tek, index: usize, color: ItemTheme) -> Perhaps<Self> {
|
||||
Ok(Some(Self::SetColor { index, color: tek.track_set_color(index, color) }))
|
||||
fn set_color (app: &mut App, index: usize, color: ItemTheme) -> Perhaps<Self> {
|
||||
Ok(Some(Self::SetColor { index, color: app.track_set_color(index, color) }))
|
||||
}
|
||||
}
|
||||
|
||||
#[tengri_proc::command(Tek)] impl SceneCommand {
|
||||
fn add (tek: &mut Tek) -> Perhaps<Self> {
|
||||
#[tengri_proc::command(App)] impl SceneCommand {
|
||||
fn add (app: &mut App) -> Perhaps<Self> {
|
||||
todo!()
|
||||
}
|
||||
fn del (tek: &mut Tek, index: usize) -> Perhaps<Self> {
|
||||
tek.scene_del(index);
|
||||
fn del (app: &mut App, index: usize) -> Perhaps<Self> {
|
||||
app.scene_del(index);
|
||||
Ok(None)
|
||||
}
|
||||
fn enqueue (tek: &mut Tek, index: usize) -> Perhaps<Self> {
|
||||
tek.scene_enqueue(index);
|
||||
fn enqueue (app: &mut App, index: usize) -> Perhaps<Self> {
|
||||
app.scene_enqueue(index);
|
||||
Ok(None)
|
||||
}
|
||||
fn set_color (tek: &mut Tek, index: usize, color: ItemTheme) -> Perhaps<Self> {
|
||||
Ok(Some(Self::SetColor { index, color: tek.scene_set_color(index, color) }))
|
||||
fn set_color (app: &mut App, index: usize, color: ItemTheme) -> Perhaps<Self> {
|
||||
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!()
|
||||
}
|
||||
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!()
|
||||
}
|
||||
fn swap (tek: &mut Tek, index: usize, other: usize) -> Perhaps<Self> {
|
||||
fn swap (app: &mut App, index: usize, other: usize) -> Perhaps<Self> {
|
||||
todo!();
|
||||
Ok(Some(Self::Swap { index, other }))
|
||||
}
|
||||
}
|
||||
|
||||
#[tengri_proc::command(Tek)] impl ClipCommand {
|
||||
fn get (tek: &mut Tek, a: usize, b: usize) -> Perhaps<Self> {
|
||||
#[tengri_proc::command(App)] impl ClipCommand {
|
||||
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] Some(Self::Get(a.unwrap(), b.unwrap())))
|
||||
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" [a: MaybeClip] Some(Self::Edit(a.unwrap())))
|
||||
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:?}"))
|
||||
//("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<Self> {
|
||||
fn put (app: &mut App, a: usize, b: usize) -> Perhaps<Self> {
|
||||
//(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<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))))
|
||||
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]
|
||||
//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<Self> {
|
||||
fn set_color (app: &mut App, a: usize, b: usize) -> Perhaps<Self> {
|
||||
//(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())))
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<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() {
|
||||
return Err(format!("missing keys definition").into())
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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<TekCommand>,
|
||||
pub history: Vec<AppCommand>,
|
||||
/// Port handles
|
||||
pub ports: std::collections::BTreeMap<u32, Port<Unowned>>,
|
||||
// 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!(<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_w = {
|
||||
let size = self.size.w();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::*;
|
||||
|
||||
impl Tek {
|
||||
impl App {
|
||||
pub fn toggle_dialog (&mut self, dialog: Option<Dialog>) {
|
||||
self.dialog = if self.dialog == dialog {
|
||||
None
|
||||
|
|
|
|||
|
|
@ -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_mut (&mut self) -> &mut Vec<Scene> { &mut self.scenes }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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_outs (&self) -> &Vec<JackMidiOut> { &self.midi_outs }
|
||||
fn tracks (&self) -> &Vec<Track> { &self.tracks }
|
||||
|
|
|
|||
|
|
@ -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<TuiOut> + use<'_> {
|
||||
"nil"
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ impl Tek {
|
|||
}
|
||||
}
|
||||
|
||||
impl Tek {
|
||||
impl App {
|
||||
fn view_dialog_menu (&self) -> impl Content<TuiOut> {
|
||||
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<TuiOut> 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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue