mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
switch sequencer to ItemColorTriplet
This commit is contained in:
parent
cb8dfb4bd7
commit
87379ff76b
5 changed files with 25 additions and 15 deletions
|
|
@ -79,7 +79,7 @@ pub enum PhrasePoolMode {
|
|||
/// All notes are displayed with minimum length
|
||||
pub percussive: bool,
|
||||
/// Identifying color of phrase
|
||||
pub color: ItemColor,
|
||||
pub color: ItemColorTriplet,
|
||||
}
|
||||
/// Contains state for viewing and editing a phrase
|
||||
pub struct PhraseEditor<E: Engine> {
|
||||
|
|
@ -205,7 +205,7 @@ impl<E: Engine> PhrasePool<E> {
|
|||
}
|
||||
return None
|
||||
}
|
||||
fn new_phrase (name: Option<&str>, color: Option<ItemColor>) -> Arc<RwLock<Phrase>> {
|
||||
fn new_phrase (name: Option<&str>, color: Option<ItemColorTriplet>) -> Arc<RwLock<Phrase>> {
|
||||
Arc::new(RwLock::new(Phrase::new(
|
||||
String::from(name.unwrap_or("(new)")), true, 4 * PPQ, None, color
|
||||
)))
|
||||
|
|
@ -216,23 +216,23 @@ impl<E: Engine> PhrasePool<E> {
|
|||
self.phrase = self.phrase.min(self.phrases.len().saturating_sub(1));
|
||||
}
|
||||
}
|
||||
pub fn append_new (&mut self, name: Option<&str>, color: Option<ItemColor>) {
|
||||
pub fn append_new (&mut self, name: Option<&str>, color: Option<ItemColorTriplet>) {
|
||||
self.phrases.push(Self::new_phrase(name, color));
|
||||
self.phrase = self.phrases.len() - 1;
|
||||
}
|
||||
pub fn insert_new (&mut self, name: Option<&str>, color: Option<ItemColor>) {
|
||||
pub fn insert_new (&mut self, name: Option<&str>, color: Option<ItemColorTriplet>) {
|
||||
self.phrases.insert(self.phrase + 1, Self::new_phrase(name, color));
|
||||
self.phrase += 1;
|
||||
}
|
||||
pub fn insert_dup (&mut self) {
|
||||
let mut phrase = self.phrases[self.phrase].read().unwrap().duplicate();
|
||||
phrase.color = ItemColor::random_near(phrase.color, 0.25);
|
||||
phrase.color = ItemColorTriplet::random_near(phrase.color, 0.25);
|
||||
self.phrases.insert(self.phrase + 1, Arc::new(RwLock::new(phrase)));
|
||||
self.phrase += 1;
|
||||
}
|
||||
pub fn randomize_color (&mut self) {
|
||||
let mut phrase = self.phrases[self.phrase].write().unwrap();
|
||||
phrase.color = ItemColor::random();
|
||||
phrase.color = ItemColorTriplet::random();
|
||||
}
|
||||
pub fn begin_rename (&mut self) {
|
||||
self.mode = Some(PhrasePoolMode::Rename(
|
||||
|
|
@ -347,7 +347,7 @@ impl Phrase {
|
|||
loop_on: bool,
|
||||
length: usize,
|
||||
notes: Option<PhraseData>,
|
||||
color: Option<ItemColor>,
|
||||
color: Option<ItemColorTriplet>,
|
||||
) -> Self {
|
||||
Self {
|
||||
uuid: uuid::Uuid::new_v4(),
|
||||
|
|
@ -359,7 +359,7 @@ impl Phrase {
|
|||
loop_start: 0,
|
||||
loop_length: length,
|
||||
percussive: true,
|
||||
color: color.unwrap_or_else(ItemColor::random)
|
||||
color: color.unwrap_or_else(ItemColorTriplet::random)
|
||||
}
|
||||
}
|
||||
pub fn duplicate (&self) -> Self {
|
||||
|
|
@ -384,7 +384,9 @@ impl Phrase {
|
|||
}
|
||||
}
|
||||
impl Default for Phrase {
|
||||
fn default () -> Self { Self::new("(empty)", false, 0, None, Some(Color::Rgb(0, 0, 0).into())) }
|
||||
fn default () -> Self {
|
||||
Self::new("(empty)", false, 0, None, Some(ItemColor::from(Color::Rgb(0, 0, 0)).into()))
|
||||
}
|
||||
}
|
||||
impl PartialEq for Phrase { fn eq (&self, other: &Self) -> bool { self.uuid == other.uuid } }
|
||||
impl Eq for Phrase {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue