mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
migrate Color -> ItemColor and remove unused
This commit is contained in:
parent
33600e890f
commit
eb1e3179a4
6 changed files with 59 additions and 76 deletions
|
|
@ -67,7 +67,7 @@ pub struct Arrangement<E: Engine> {
|
|||
/// Whether the arranger is currently focused
|
||||
pub focused: bool,
|
||||
/// Background color of arrangement
|
||||
pub color: Color,
|
||||
pub color: ItemColor,
|
||||
/// Width and height of arrangement area at last render
|
||||
pub size: Measure<E>,
|
||||
}
|
||||
|
|
@ -78,7 +78,7 @@ pub struct ArrangementTrack {
|
|||
/// Preferred width of track column
|
||||
pub width: usize,
|
||||
/// Identifying color of track
|
||||
pub color: Color,
|
||||
pub color: ItemColor,
|
||||
/// MIDI player/recorder
|
||||
pub player: PhrasePlayer,
|
||||
}
|
||||
|
|
@ -89,7 +89,7 @@ pub struct Scene {
|
|||
/// Clips in scene, one per track
|
||||
pub clips: Vec<Option<Arc<RwLock<Phrase>>>>,
|
||||
/// Identifying color of scene
|
||||
pub color: Color,
|
||||
pub color: ItemColor,
|
||||
}
|
||||
#[derive(PartialEq, Clone, Copy)]
|
||||
/// Represents the current user selection in the arranger
|
||||
|
|
@ -232,7 +232,7 @@ impl<E: Engine> Arrangement<E> {
|
|||
scenes: vec![],
|
||||
tracks: vec![],
|
||||
focused: false,
|
||||
color: Color::Rgb(28, 35, 25),
|
||||
color: Color::Rgb(28, 35, 25).into(),
|
||||
size: Measure::new(),
|
||||
}
|
||||
}
|
||||
|
|
@ -374,11 +374,11 @@ impl<E: Engine> Arrangement<E> {
|
|||
}
|
||||
pub fn randomize_color (&mut self) {
|
||||
match self.selected {
|
||||
ArrangementFocus::Mix => { self.color = random_color_dark() },
|
||||
ArrangementFocus::Track(t) => { self.tracks[t].color = random_color() },
|
||||
ArrangementFocus::Scene(s) => { self.scenes[s].color = random_color() },
|
||||
ArrangementFocus::Mix => { self.color = ItemColor::random_dark() },
|
||||
ArrangementFocus::Track(t) => { self.tracks[t].color = ItemColor::random() },
|
||||
ArrangementFocus::Scene(s) => { self.scenes[s].color = ItemColor::random() },
|
||||
ArrangementFocus::Clip(t, s) => if let Some(phrase) = &self.scenes[s].clips[t] {
|
||||
phrase.write().unwrap().color = random_color();
|
||||
phrase.write().unwrap().color = ItemColor::random();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -396,7 +396,7 @@ impl<E: Engine> Arrangement<E> {
|
|||
pub fn track_next (&mut self) { self.selected.track_next(self.tracks.len() - 1) }
|
||||
pub fn track_prev (&mut self) { self.selected.track_prev() }
|
||||
pub fn track_add (
|
||||
&mut self, name: Option<&str>, color: Option<Color>
|
||||
&mut self, name: Option<&str>, color: Option<ItemColor>
|
||||
) -> Usually<&mut ArrangementTrack> {
|
||||
self.tracks.push(name.map_or_else(
|
||||
|| ArrangementTrack::new(&self.clock, &self.track_default_name(), color),
|
||||
|
|
@ -442,7 +442,7 @@ impl<E: Engine> Arrangement<E> {
|
|||
pub fn scene_prev (&mut self) {
|
||||
self.selected.scene_prev()
|
||||
}
|
||||
pub fn scene_add (&mut self, name: Option<&str>, color: Option<Color>) -> Usually<&mut Scene> {
|
||||
pub fn scene_add (&mut self, name: Option<&str>, color: Option<ItemColor>) -> Usually<&mut Scene> {
|
||||
let clips = vec![None;self.tracks.len()];
|
||||
let name = name.map(|x|x.to_string()).unwrap_or_else(||self.scene_default_name());
|
||||
self.scenes.push(Scene::new(name, clips, color));
|
||||
|
|
@ -523,11 +523,11 @@ impl<E: Engine> Arrangement<E> {
|
|||
}
|
||||
}
|
||||
impl ArrangementTrack {
|
||||
pub fn new (clock: &Arc<TransportTime>, name: &str, color: Option<Color>) -> Self {
|
||||
pub fn new (clock: &Arc<TransportTime>, name: &str, color: Option<ItemColor>) -> Self {
|
||||
Self {
|
||||
name: Arc::new(RwLock::new(name.into())),
|
||||
width: name.len() + 2,
|
||||
color: color.unwrap_or_else(random_color),
|
||||
color: color.unwrap_or_else(ItemColor::random),
|
||||
player: PhrasePlayer::new(clock),
|
||||
}
|
||||
}
|
||||
|
|
@ -640,12 +640,12 @@ impl Scene {
|
|||
pub fn new (
|
||||
name: impl AsRef<str>,
|
||||
clips: impl AsRef<[Option<Arc<RwLock<Phrase>>>]>,
|
||||
color: Option<Color>,
|
||||
color: Option<ItemColor>,
|
||||
) -> Self {
|
||||
Self {
|
||||
name: Arc::new(RwLock::new(name.as_ref().into())),
|
||||
clips: clips.as_ref().iter().map(|x|x.clone()).collect(),
|
||||
color: color.unwrap_or_else(random_color),
|
||||
color: color.unwrap_or_else(ItemColor::random),
|
||||
}
|
||||
}
|
||||
/// Returns the pulse length of the longest phrase in the scene
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue