mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 03:36:41 +01:00
replace track_next_name with monotonic counter
Some checks are pending
/ build (push) Waiting to run
Some checks are pending
/ build (push) Waiting to run
This commit is contained in:
parent
3c2d490f83
commit
7b432d12b4
1 changed files with 7 additions and 4 deletions
|
|
@ -26,6 +26,8 @@ pub struct Tek {
|
|||
pub note_buf: Vec<u8>,
|
||||
/// Buffer for writing a chunk of midi events
|
||||
pub midi_buf: Vec<Vec<Vec<u8>>>,
|
||||
/// Last track number (to avoid duplicate port names)
|
||||
pub track_last: usize,
|
||||
/// List of tracks
|
||||
pub tracks: Vec<Track>,
|
||||
/// Scroll offset of tracks
|
||||
|
|
@ -87,7 +89,11 @@ impl Tek {
|
|||
mins: &[PortConnect],
|
||||
mouts: &[PortConnect],
|
||||
) -> Usually<(usize, &mut Track)> {
|
||||
let name = name.map_or_else(||self.track_next_name(), |x|x.to_string().into());
|
||||
self.track_last += 1;
|
||||
let name: Arc<str> = name.map_or_else(
|
||||
||format!("Track{:02}", self.track_last).into(),
|
||||
|x|x.to_string().into()
|
||||
);
|
||||
let mut track = Track {
|
||||
width: (name.len() + 2).max(12),
|
||||
color: color.unwrap_or_else(ItemTheme::random),
|
||||
|
|
@ -594,9 +600,6 @@ pub trait HasTracks: HasSelection + HasClock + HasJack + HasEditor + Send + Sync
|
|||
self.tracks().iter().map(|s|s.name.len()).fold(0, usize::max)
|
||||
}
|
||||
const WIDTH_OFFSET: usize = 1;
|
||||
fn track_next_name (&self) -> Arc<str> {
|
||||
format!("Track{:02}", self.tracks().len() + 1).into()
|
||||
}
|
||||
fn track (&self) -> Option<&Track> {
|
||||
self.selected().track().and_then(|s|self.tracks().get(s))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue