fix changing colors of scenes and tracks

This commit is contained in:
🪞👃🪞 2025-01-16 19:42:19 +01:00
parent a670320533
commit 3030f28ef7
4 changed files with 46 additions and 17 deletions

View file

@ -8,7 +8,7 @@
(@d select :track-next :scene) (@d select :track-next :scene)
(@q enqueue :clip) (@q enqueue :clip)
(@c clip color) (@c clip color :track :scene)
(@g clip get) (@g clip get)
(@p clip put) (@p clip put)
(@delete clip del) (@delete clip del)

View file

@ -6,7 +6,7 @@
(@d select :track-next :scene) (@d select :track-next :scene)
(@q scene launch) (@q scene launch)
(@c scene color) (@c scene color :scene)
(@comma scene prev) (@comma scene prev)
(@period scene next) (@period scene next)
(@lt scene swap-prev) (@lt scene swap-prev)

View file

@ -6,7 +6,7 @@
(@s select :track :scene-next) (@s select :track :scene-next)
(@q track launch) (@q track launch)
(@c track color) (@c track color :track)
(@comma track prev) (@comma track prev)
(@period track next) (@period track next)
(@lt track swap-prev) (@lt track swap-prev)

View file

@ -661,7 +661,7 @@ edn_command!(TekCommand: |app: Tek| {
(0, s) => Self::Select(Selection::Scene(s)), (0, s) => Self::Select(Selection::Scene(s)),
(t, s) => Self::Select(Selection::Clip(t, s)), (t, s) => Self::Select(Selection::Clip(t, s)),
}) })
("clip" [a, b, ..c] Self::Clip(ClipCommand::from_edn(app, &b.to_ref(), c) ("clip" [a, ..b] Self::Clip(ClipCommand::from_edn(app, &a.to_ref(), b)
.expect("invalid command"))) .expect("invalid command")))
("clock" [a, ..b] Self::Clock(ClockCommand::from_edn(app.clock(), &a.to_ref(), b) ("clock" [a, ..b] Self::Clock(ClockCommand::from_edn(app.clock(), &a.to_ref(), b)
.expect("invalid command"))) .expect("invalid command")))
@ -735,9 +735,38 @@ command!(|self: TekCommand, app: Tek|match self {
Self::Enqueue(clip) => app.player.as_mut() Self::Enqueue(clip) => app.player.as_mut()
.map(|player|{player.enqueue_next(clip.as_ref());None}).flatten(), .map(|player|{player.enqueue_next(clip.as_ref());None}).flatten(),
Self::Color(palette) => { Self::Color(palette) => {
let old = app.color; use Selection::*;
app.color = palette; Some(Self::Color(match app.selected {
Some(Self::Color(old)) Mix => {
let old = app.color;
app.color = palette;
old
},
Track(t) => {
let t = t.saturating_sub(1);
let old = app.tracks[t].color;
app.tracks[t].color = palette;
old
}
Scene(s) => {
let s = s.saturating_sub(1);
let old = app.scenes[s].color;
app.scenes[s].color = palette;
old
}
Clip(t, s) => {
let t = t.saturating_sub(1);
let s = s.saturating_sub(1);
if let Some(ref clip) = app.scenes[s].clips[t] {
let mut clip = clip.write().unwrap();
let old = clip.color;
clip.color = palette;
old
} else {
return Ok(None)
}
}
}))
}, },
Self::StopAll => { Self::StopAll => {
for track in 0..app.tracks.len(){app.tracks[track].player.enqueue_next(None);} for track in 0..app.tracks.len(){app.tracks[track].player.enqueue_next(None);}
@ -845,9 +874,9 @@ edn_command!(TrackCommand: |app: Tek| {
("add" [] Self::Add) ("add" [] Self::Add)
("size" [a: usize] Self::SetSize(a.unwrap())) ("size" [a: usize] Self::SetSize(a.unwrap()))
("zoom" [a: usize] Self::SetZoom(a.unwrap())) ("zoom" [a: usize] Self::SetZoom(a.unwrap()))
("color" [a: usize] Self::SetColor(a.unwrap(), ItemPalette::random())) ("color" [a: usize] Self::SetColor(a.unwrap().saturating_sub(1), ItemPalette::random()))
("del" [a: usize] Self::Del(a.unwrap())) ("del" [a: usize] Self::Del(a.unwrap().saturating_sub(1)))
("stop" [a: usize] Self::Stop(a.unwrap())) ("stop" [a: usize] Self::Stop(a.unwrap().saturating_sub(1)))
("swap" [a: usize, b: usize] Self::Swap(a.unwrap(), b.unwrap())) ("swap" [a: usize, b: usize] Self::Swap(a.unwrap(), b.unwrap()))
}); });
command!(|self: TrackCommand, app: Tek|match self { command!(|self: TrackCommand, app: Tek|match self {
@ -1017,8 +1046,8 @@ edn_command!(SceneCommand: |app: Tek| {
("add" [] Self::Add) ("add" [] Self::Add)
("del" [a: usize] Self::Del(0)) ("del" [a: usize] Self::Del(0))
("zoom" [a: usize] Self::SetZoom(a.unwrap())) ("zoom" [a: usize] Self::SetZoom(a.unwrap()))
("color" [a: usize] Self::SetColor(a.unwrap(), ItemPalette::random())) ("color" [a: usize] Self::SetColor(a.unwrap().saturating_sub(1), ItemPalette::random()))
("enqueue" [a: usize] Self::Enqueue(a.unwrap())) ("enqueue" [a: usize] Self::Enqueue(a.unwrap().saturating_sub(1)))
("swap" [a: usize, b: usize] Self::Swap(a.unwrap(), b.unwrap())) ("swap" [a: usize, b: usize] Self::Swap(a.unwrap(), b.unwrap()))
}); });
command!(|self: SceneCommand, app: Tek|match self { command!(|self: SceneCommand, app: Tek|match self {
@ -1121,17 +1150,17 @@ trait HasScenes: HasSelection + HasEditor + Send + Sync {
} }
edn_command!(ClipCommand: |app: Tek| { edn_command!(ClipCommand: |app: Tek| {
("get" [a: usize ,b: usize] ("get" [a: usize ,b: usize]
Self::Get(a.unwrap(), b.unwrap())) Self::Get(a.unwrap().saturating_sub(1), b.unwrap().saturating_sub(1)))
("put" [a: usize, b: usize, c: Option<Arc<RwLock<MidiClip>>>] ("put" [a: usize, b: usize, c: Option<Arc<RwLock<MidiClip>>>]
Self::Put(a.unwrap(), b.unwrap(), c.unwrap())) Self::Put(a.unwrap().saturating_sub(1), b.unwrap().saturating_sub(1), c.unwrap()))
("enqueue" [a: usize, b: usize] ("enqueue" [a: usize, b: usize]
Self::Enqueue(a.unwrap(), b.unwrap())) Self::Enqueue(a.unwrap().saturating_sub(1), b.unwrap().saturating_sub(1)))
("edit" [a: Option<Arc<RwLock<MidiClip>>>] ("edit" [a: Option<Arc<RwLock<MidiClip>>>]
Self::Edit(a.unwrap())) Self::Edit(a.unwrap()))
("loop" [a: usize, b: usize, c: bool] ("loop" [a: usize, b: usize, c: bool]
Self::SetLoop(a.unwrap(), b.unwrap(), c.unwrap())) Self::SetLoop(a.unwrap().saturating_sub(1), b.unwrap().saturating_sub(1), c.unwrap()))
("color" [a: usize, b: usize] ("color" [a: usize, b: usize]
Self::SetColor(a.unwrap(), b.unwrap(), ItemPalette::random())) Self::SetColor(a.unwrap().saturating_sub(1), b.unwrap().saturating_sub(1), ItemPalette::random()))
}); });
command!(|self: ClipCommand, app: Tek|match self { command!(|self: ClipCommand, app: Tek|match self {
Self::Get(track, scene) => { todo!() }, Self::Get(track, scene) => { todo!() },