rename phrase -> clip mostly everywhere

This commit is contained in:
🪞👃🪞 2025-01-10 02:12:31 +01:00
parent 709391ff0a
commit 08f7a62692
24 changed files with 426 additions and 423 deletions

View file

@ -12,10 +12,10 @@ render!(TuiOut: (self: ClipSelected) =>
impl ClipSelected {
/// Shows currently playing phrase with beats elapsed
pub fn play_phrase <T: HasPlayPhrase + HasClock> (state: &T) -> Self {
let (name, color) = if let Some((_, Some(phrase))) = state.play_phrase() {
let MidiClip { ref name, color, .. } = *phrase.read().unwrap();
/// Shows currently playing clip with beats elapsed
pub fn play_clip <T: HasPlayPhrase + HasClock> (state: &T) -> Self {
let (name, color) = if let Some((_, Some(clip))) = state.play_clip() {
let MidiClip { ref name, color, .. } = *clip.read().unwrap();
(name.clone().into(), color)
} else {
("".to_string().into(), TuiTheme::g(64).into())
@ -32,15 +32,15 @@ impl ClipSelected {
}
}
/// Shows next phrase with beats remaining until switchover
pub fn next_phrase <T: HasPlayPhrase> (state: &T) -> Self {
/// Shows next clip with beats remaining until switchover
pub fn next_clip <T: HasPlayPhrase> (state: &T) -> Self {
let mut time: Arc<str> = String::from("--.-.--").into();
let mut name: Arc<str> = String::from("").into();
let mut color = ItemPalette::from(TuiTheme::g(64));
if let Some((t, Some(phrase))) = state.next_phrase() {
let phrase = phrase.read().unwrap();
name = phrase.name.clone();
color = phrase.color.clone();
if let Some((t, Some(clip))) = state.next_clip() {
let clip = clip.read().unwrap();
name = clip.name.clone();
color = clip.color.clone();
time = {
let target = t.pulse.get();
let current = state.clock().playhead.pulse.get();
@ -51,12 +51,12 @@ impl ClipSelected {
String::new()
}
}.into()
} else if let Some((t, Some(phrase))) = state.play_phrase() {
let phrase = phrase.read().unwrap();
if phrase.looped {
name = phrase.name.clone();
color = phrase.color.clone();
let target = t.pulse.get() + phrase.length as f64;
} else if let Some((t, Some(clip))) = state.play_clip() {
let clip = clip.read().unwrap();
if clip.looped {
name = clip.name.clone();
color = clip.color.clone();
let target = t.pulse.get() + clip.length as f64;
let current = state.clock().playhead.pulse.get();
if target > current {
time = format!("-{:>}", state.clock().timebase.format_beats_0(