store updated phrase length; enter/exit phrase editor

This commit is contained in:
🪞👃🪞 2024-10-16 12:29:45 +03:00
parent ff342963a1
commit d29dd56198
3 changed files with 42 additions and 34 deletions

View file

@ -168,15 +168,17 @@ impl<E: Engine> PhrasePool<E> {
}
pub fn append_new (&mut self, name: Option<&str>, color: Option<Color>) {
let mut phrase = Phrase::default();
phrase.name = String::from(name.unwrap_or("(no name)"));
phrase.color = color.unwrap_or_else(random_color);
phrase.name = String::from(name.unwrap_or("(no name)"));
phrase.color = color.unwrap_or_else(random_color);
phrase.length = 4 * PPQ;
self.phrases.push(Arc::new(RwLock::new(phrase)));
self.phrase = self.phrases.len() - 1;
}
pub fn insert_new (&mut self, name: Option<&str>, color: Option<Color>) {
let mut phrase = Phrase::default();
phrase.name = String::from(name.unwrap_or("(no name)"));
phrase.color = color.unwrap_or_else(random_color);
phrase.name = String::from(name.unwrap_or("(no name)"));
phrase.color = color.unwrap_or_else(random_color);
phrase.length = 4 * PPQ;
self.phrases.insert(self.phrase + 1, Arc::new(RwLock::new(phrase)));
self.phrase += 1;
}