mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
put phrases from pool in arrangement
This commit is contained in:
parent
dc3edc86ff
commit
96ca1e148b
4 changed files with 14 additions and 4 deletions
|
|
@ -347,6 +347,11 @@ impl<E: Engine> Arrangement<E> {
|
|||
//})
|
||||
//});
|
||||
}
|
||||
pub fn phrase_put (&mut self) {
|
||||
if let ArrangementFocus::Clip(track, scene) = self.selected {
|
||||
self.scenes[scene].clips[track] = Some(self.phrases.read().unwrap().phrase().clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
impl<E: Engine> ArrangementTrack<E> {
|
||||
pub fn new (name: &str) -> Self {
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@ impl Handle<Tui> for Arranger<Tui> {
|
|||
key!(KeyCode::Down) => { self.focus_down(); },
|
||||
key!(KeyCode::Left) => { self.focus_left(); },
|
||||
key!(KeyCode::Right) => { self.focus_right(); },
|
||||
// Put selected phrase at position
|
||||
key!(KeyCode::Char('s')) => { self.arrangement.phrase_put(); },
|
||||
// Global play/pause binding
|
||||
key!(KeyCode::Char(' ')) => match self.transport {
|
||||
Some(ref mut transport) => { transport.write().unwrap().toggle_play()?; },
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ pub struct PhrasePool<E: Engine> {
|
|||
/// Highlighted phrase
|
||||
pub phrase: usize,
|
||||
/// Phrases in the pool
|
||||
pub phrases: Vec<Arc<RwLock<Option<Phrase>>>>,
|
||||
pub phrases: Vec<Arc<RwLock<Phrase>>>,
|
||||
/// Whether this widget is focused
|
||||
pub focused: bool,
|
||||
}
|
||||
|
|
@ -126,10 +126,13 @@ impl<E: Engine> PhrasePool<E> {
|
|||
_engine: Default::default(),
|
||||
scroll: 0,
|
||||
phrase: 0,
|
||||
phrases: vec![Arc::new(RwLock::new(Some(Phrase::default())))],
|
||||
phrases: vec![Arc::new(RwLock::new(Phrase::default()))],
|
||||
focused: false
|
||||
}
|
||||
}
|
||||
pub fn phrase (&self) -> &Arc<RwLock<Phrase>> {
|
||||
&self.phrases[self.phrase]
|
||||
}
|
||||
}
|
||||
impl<E: Engine> PhraseEditor<E> {
|
||||
pub fn new () -> Self {
|
||||
|
|
|
|||
|
|
@ -76,10 +76,10 @@ impl Handle<Tui> for PhrasePool<Tui> {
|
|||
self.phrase = (self.phrase + 1) % self.phrases.len()
|
||||
},
|
||||
key!(KeyCode::Char('i')) => {
|
||||
self.phrases.insert(self.phrase, Arc::new(RwLock::new(Some(Phrase::default()))))
|
||||
self.phrases.insert(self.phrase, Arc::new(RwLock::new(Phrase::default())))
|
||||
},
|
||||
key!(KeyCode::Char('a')) => {
|
||||
self.phrases.push(Arc::new(RwLock::new(Some(Phrase::default()))))
|
||||
self.phrases.push(Arc::new(RwLock::new(Phrase::default())))
|
||||
},
|
||||
_ => return Ok(None),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue