unify init naming; GrooveboxTui -> Groovebox

This commit is contained in:
🪞👃🪞 2024-12-29 20:32:00 +01:00
parent 6607491f16
commit 0c9c386a79
7 changed files with 20 additions and 20 deletions

View file

@ -34,11 +34,8 @@ pub struct ArrangerCli {
impl ArrangerCli { impl ArrangerCli {
/// Run the arranger TUI from CLI arguments. /// Run the arranger TUI from CLI arguments.
fn run (&self) -> Usually<()> { fn run (&self) -> Usually<()> {
let mut client_name = String::from("tek_arranger"); let name = self.name.as_deref().unwrap_or("tek_arranger");
if let Some(name) = self.name.as_ref() { Tui::run(JackConnection::new(name)?.activate_with(|jack|{
client_name = name.clone();
}
Tui::run(JackConnection::new(client_name.as_str())?.activate_with(|jack|{
let mut app = ArrangerTui::try_from(jack)?; let mut app = ArrangerTui::try_from(jack)?;
let jack = jack.read().unwrap(); let jack = jack.read().unwrap();
app.color = ItemPalette::random(); app.color = ItemPalette::random();

View file

@ -36,8 +36,9 @@ pub struct GrooveboxCli {
} }
impl GrooveboxCli { impl GrooveboxCli {
fn run (&self) -> Usually<()> { fn run (&self) -> Usually<()> {
Tui::run(JackConnection::new("tek_groovebox")?.activate_with(|jack|{ let name = self.name.as_deref().unwrap_or("tek_groovebox");
let app = tek::GrooveboxTui::new( Tui::run(JackConnection::new(name)?.activate_with(|jack|{
let app = tek::Groovebox::new(
jack, jack,
&self.midi_from.as_slice(), &self.midi_from.as_slice(),
&self.midi_to.as_slice(), &self.midi_to.as_slice(),

View file

@ -23,7 +23,8 @@ pub fn main () -> Usually<()> { SamplerCli::parse().run() }
} }
impl SamplerCli { impl SamplerCli {
fn run (&self) -> Usually<()> { fn run (&self) -> Usually<()> {
Tui::run(JackConnection::new("tek_sampler")?.activate_with(|jack|{ let name = self.name.as_deref().unwrap_or("tek_sampler");
Tui::run(JackConnection::new(name)?.activate_with(|jack|{
Ok(tek::SamplerTui { Ok(tek::SamplerTui {
cursor: (0, 0), cursor: (0, 0),
editing: None, editing: None,

View file

@ -2,7 +2,8 @@ include!("./lib.rs");
/// Application entrypoint. /// Application entrypoint.
pub fn main () -> Usually<()> { pub fn main () -> Usually<()> {
Tui::run(JackConnection::new("tek_transport")?.activate_with(|jack|{ let name = self.name.as_deref().unwrap_or("tek_transport");
Tui::run(JackConnection::new(name)?.activate_with(|jack|{
TransportTui::try_from(jack) TransportTui::try_from(jack)
})?)?; })?)?;
Ok(()) Ok(())

View file

@ -6,7 +6,7 @@ use GrooveboxCommand::*;
use PhraseCommand::*; use PhraseCommand::*;
use PhrasePoolCommand::*; use PhrasePoolCommand::*;
pub struct GrooveboxTui { pub struct Groovebox {
_jack: Arc<RwLock<JackConnection>>, _jack: Arc<RwLock<JackConnection>>,
pub player: MidiPlayer, pub player: MidiPlayer,
@ -20,7 +20,7 @@ pub struct GrooveboxTui {
pub midi_buf: Vec<Vec<Vec<u8>>>, pub midi_buf: Vec<Vec<Vec<u8>>>,
pub perf: PerfModel, pub perf: PerfModel,
} }
impl GrooveboxTui { impl Groovebox {
pub fn new ( pub fn new (
jack: &Arc<RwLock<JackConnection>>, jack: &Arc<RwLock<JackConnection>>,
midi_from: &[impl AsRef<str>], midi_from: &[impl AsRef<str>],
@ -64,8 +64,8 @@ impl GrooveboxTui {
}) })
} }
} }
has_clock!(|self: GrooveboxTui|self.player.clock()); has_clock!(|self: Groovebox|self.player.clock());
audio!(|self: GrooveboxTui, client, scope|{ audio!(|self: Groovebox, client, scope|{
let t0 = self.perf.get_t0(); let t0 = self.perf.get_t0();
if Control::Quit == ClockAudio(&mut self.player).process(client, scope) { if Control::Quit == ClockAudio(&mut self.player).process(client, scope) {
return Control::Quit return Control::Quit
@ -111,7 +111,7 @@ audio!(|self: GrooveboxTui, client, scope|{
self.perf.update(t0, scope); self.perf.update(t0, scope);
Control::Continue Control::Continue
}); });
render!(<Tui>|self:GrooveboxTui|{ render!(<Tui>|self:Groovebox|{
let w = self.size.w(); let w = self.size.w();
let phrase_w = if w > 60 { 20 } else if w > 40 { 15 } else { 10 }; let phrase_w = if w > 60 { 20 } else if w > 40 { 15 } else { 10 };
let pool_w = if self.pool.visible { phrase_w } else { 0 }; let pool_w = if self.pool.visible { phrase_w } else { 0 };
@ -165,7 +165,7 @@ render!(<Tui>|self:GrooveboxTui|{
])) ]))
}); });
struct GrooveboxSamples<'a>(&'a GrooveboxTui); struct GrooveboxSamples<'a>(&'a Groovebox);
render!(<Tui>|self: GrooveboxSamples<'a>|{ render!(<Tui>|self: GrooveboxSamples<'a>|{
let note_lo = self.0.editor.note_lo().load(Relaxed); let note_lo = self.0.editor.note_lo().load(Relaxed);
let note_pt = self.0.editor.note_point(); let note_pt = self.0.editor.note_point();
@ -198,9 +198,9 @@ pub enum GrooveboxCommand {
Sampler(SamplerCommand), Sampler(SamplerCommand),
} }
handle!(<Tui>|self: GrooveboxTui, input|GrooveboxCommand::execute_with_state(self, input)); handle!(<Tui>|self: Groovebox, input|GrooveboxCommand::execute_with_state(self, input));
input_to_command!(GrooveboxCommand: <Tui>|state: GrooveboxTui, input|match input.event() { input_to_command!(GrooveboxCommand: <Tui>|state: Groovebox, input|match input.event() {
// TODO: k: toggle on-screen keyboard // TODO: k: toggle on-screen keyboard
key_pat!(Ctrl-Char('k')) => { key_pat!(Ctrl-Char('k')) => {
todo!("keyboard") todo!("keyboard")
@ -249,7 +249,7 @@ input_to_command!(GrooveboxCommand: <Tui>|state: GrooveboxTui, input|match input
} }
}); });
command!(|self:GrooveboxCommand,state:GrooveboxTui|match self { command!(|self: GrooveboxCommand, state: Groovebox|match self {
Self::Pool(cmd) => { Self::Pool(cmd) => {
let mut default = |cmd: PoolCommand|cmd let mut default = |cmd: PoolCommand|cmd
.execute(&mut state.pool) .execute(&mut state.pool)

View file

@ -40,7 +40,7 @@ pub mod plugin; pub(crate) use self::plugin::*;
pub use self::plugin::*; pub use self::plugin::*;
pub mod groovebox; pub(crate) use self::groovebox::*; pub mod groovebox; pub(crate) use self::groovebox::*;
pub use self::groovebox::GrooveboxTui; pub use self::groovebox::Groovebox;
pub mod pool; pub(crate) use self::pool::*; pub mod pool; pub(crate) use self::pool::*;
pub use self::pool::PoolModel; pub use self::pool::PoolModel;

View file

@ -8,7 +8,7 @@ pub struct GrooveboxStatus {
pub(crate) size: String, pub(crate) size: String,
pub(crate) playing: bool, pub(crate) playing: bool,
} }
from!(|state:&GrooveboxTui|GrooveboxStatus = { from!(|state: &Groovebox|GrooveboxStatus = {
let samples = state.clock().chunk.load(Relaxed); let samples = state.clock().chunk.load(Relaxed);
let rate = state.clock().timebase.sr.get(); let rate = state.clock().timebase.sr.get();
let buffer = samples as f64 / rate; let buffer = samples as f64 / rate;