update initial track width

This commit is contained in:
🪞👃🪞 2025-01-22 00:19:17 +01:00
parent bbe49ad463
commit b306059dbc
8 changed files with 25 additions and 18 deletions

View file

@ -48,7 +48,7 @@ pub struct TekCli {
/// Number of tracks
#[arg(short = 'x', long, default_value_t = 1)] tracks: usize,
/// Width of tracks
#[arg(short = 'w', long, default_value_t = 9)] track_width: usize,
#[arg(short = 'w', long, default_value_t = 12)] track_width: usize,
},
/// TODO: A MIDI-controlled audio mixer
Mixer,
@ -111,6 +111,8 @@ impl Tek {
keys_track: SourceIter(KEYS_TRACK),
keys_scene: SourceIter(KEYS_SCENE),
keys_mix: SourceIter(KEYS_MIX),
tracks: vec![],
scenes: vec![],
..Default::default()
};
jack.sync_lead(sync_lead, |mut state|{
@ -173,10 +175,12 @@ impl Tek {
editor: Some(Default::default()),
editing: false.into(),
midi_buf: vec![vec![];65536],
tracks: vec![],
scenes: vec![],
..Self::new_clock(jack, bpm, sync_lead, sync_follow, midi_froms, midi_tos)?
};
arranger.scenes_add(scenes);
arranger.tracks_add(tracks, track_width, midi_froms, midi_tos);
arranger.tracks_add(tracks, Some(track_width), midi_froms, midi_tos);
arranger.selected = Selection::Clip(1, 1);
Ok(arranger)
}

View file

@ -62,7 +62,7 @@ atom_command!(TekCommand: |app: Tek| {
(t, s) => Self::Select(Selection::Clip(t, s)),
})
("clip" [,..a] Self::Clip(
ClipCommand::try_from_expr(app, a).expect("invalid command")))
ClipCommand::try_from_expr(app, a).expect("invalid command: {a:?}")))
("clock" [,..a] Self::Clock(
ClockCommand::try_from_expr(app.clock(), a).expect("invalid command")))
("editor" [,..a] Self::Editor(
@ -190,7 +190,7 @@ command!(|self: TekCommand, app: Tek|match self {
} else {
None
},
_ => todo!()
_ => todo!("{self:?}")
});
#[derive(Clone, Debug)] pub enum TrackCommand {
Add,

View file

@ -7,7 +7,7 @@
(@right select :track-next :scene)
(@d select :track-next :scene)
(@q enqueue :track :scene)
(@q clip launch :track :scene)
(@c clip color :track :scene)
(@g clip get)
(@p clip put)

View file

@ -5,7 +5,7 @@
(@right select :track-next :scene)
(@d select :track-next :scene)
(@q scene launch)
(@q scene launch :scene)
(@c scene color :scene)
(@comma scene prev)
(@period scene next)

View file

@ -5,7 +5,7 @@
(@down select :track :scene-next)
(@s select :track :scene-next)
(@q track launch)
(@q track launch :track)
(@c track color :track)
(@comma track prev)
(@period track next)

View file

@ -5,7 +5,11 @@
#![feature(if_let_guard)]
#![feature(impl_trait_in_assoc_type)]
#![feature(type_alias_impl_trait)]
pub(crate) use std::sync::{Arc, RwLock, atomic::{AtomicBool, Ordering::Relaxed}};
mod cli; pub use self::cli::*;
mod model; pub use self::model::*;
mod view; pub use self::view::*;
mod keys; pub use self::keys::*;
mod audio; pub use self::audio::*;
/// Standard result type.
pub type Usually<T> = std::result::Result<T, Box<dyn std::error::Error>>;
/// Standard optional result type.
@ -22,8 +26,5 @@ pub use ::tek_tui::{
Event, KeyEvent, KeyEventKind, KeyEventState, KeyModifiers, KeyCode::{self, *},
},
};
mod cli; pub use self::cli::*;
mod model; pub use self::model::*;
mod view; pub use self::view::*;
mod keys; pub use self::keys::*;
mod audio; pub use self::audio::*;
pub(crate) use std::sync::{Arc, RwLock, atomic::{AtomicBool, Ordering::Relaxed}};

View file

@ -91,7 +91,7 @@ impl Tek {
format!("Sc{:3>}", self.scenes().len() + 1).into()
}
pub fn tracks_add (
&mut self, count: usize, width: usize,
&mut self, count: usize, width: Option<usize>,
midi_from: &[PortConnect], midi_to: &[PortConnect],
) -> Usually<()> {
let jack = self.jack().clone();
@ -100,7 +100,9 @@ impl Tek {
for i in 0..count {
let color = track_color_1.mix(track_color_2, i as f32 / count as f32).into();
let mut track = self.track_add(None, Some(color), midi_from, midi_to)?.1;
track.width = width;
if let Some(width) = width {
track.width = width;
}
}
Ok(())
}
@ -111,7 +113,7 @@ impl Tek {
) -> Usually<(usize, &mut Track)> {
let name = name.map_or_else(||self.track_next_name(), |x|x.to_string().into());
let mut track = Track {
width: (name.len() + 2).max(9),
width: (name.len() + 2).max(12),
color: color.unwrap_or_else(ItemPalette::random),
player: MidiPlayer::new(
&format!("{name}"),

View file

@ -53,8 +53,8 @@ impl Default for ViewCache {
view!(TuiOut: |self: Tek| self.size.of(View(self, self.view)); {
":editor" => (&self.editor).boxed(),
":pool" => self.view_pool().boxed(),
//":sample" => self.view_sample(self.is_editing()).boxed(),
//":sampler" => self.view_sampler(self.is_editing(), &self.editor).boxed(),
":sample" => ().boxed(),//self.view_sample(self.is_editing()).boxed(),
":sampler" => ().boxed(),//self.view_sampler(self.is_editing(), &self.editor).boxed(),
":status" => self.view_editor().boxed(),
":toolbar" => self.view_clock().boxed(),
":tracks" => self.view_tracks().boxed(),