mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
enable enqueueing clips and scenes
This commit is contained in:
parent
9776d3e665
commit
e8c92158da
4 changed files with 83 additions and 61 deletions
|
|
@ -6,7 +6,6 @@ use KeyCode::{Char, Delete, Tab};
|
||||||
Undo,
|
Undo,
|
||||||
Redo,
|
Redo,
|
||||||
Clear,
|
Clear,
|
||||||
StopAll,
|
|
||||||
Color(ItemPalette),
|
Color(ItemPalette),
|
||||||
Clock(ClockCommand),
|
Clock(ClockCommand),
|
||||||
Scene(ArrangerSceneCommand),
|
Scene(ArrangerSceneCommand),
|
||||||
|
|
@ -17,7 +16,12 @@ use KeyCode::{Char, Delete, Tab};
|
||||||
Phrases(PhrasesCommand),
|
Phrases(PhrasesCommand),
|
||||||
Editor(PhraseCommand),
|
Editor(PhraseCommand),
|
||||||
ShowPool(bool),
|
ShowPool(bool),
|
||||||
Put(usize, usize, Option<Arc<RwLock<Phrase>>>),
|
GetClip(usize, usize),
|
||||||
|
PutClip(usize, usize, Option<Arc<RwLock<Phrase>>>),
|
||||||
|
EnqueueClip(usize, usize),
|
||||||
|
EnqueueScene(usize),
|
||||||
|
StopTrack(usize),
|
||||||
|
StopAll,
|
||||||
}
|
}
|
||||||
input_to_command!(ArrangerCommand: <Tui>|state: ArrangerTui, input|{
|
input_to_command!(ArrangerCommand: <Tui>|state: ArrangerTui, input|{
|
||||||
use ArrangerSelection as Selected;
|
use ArrangerSelection as Selected;
|
||||||
|
|
@ -69,8 +73,8 @@ input_to_command!(ArrangerCommand: <Tui>|state: ArrangerTui, input|{
|
||||||
key_pat!(Char('<')) => Some(Self::Clip(Clip::Set(t, s, None))),
|
key_pat!(Char('<')) => Some(Self::Clip(Clip::Set(t, s, None))),
|
||||||
key_pat!(Char('>')) => Some(Self::Clip(Clip::Set(t, s, None))),
|
key_pat!(Char('>')) => Some(Self::Clip(Clip::Set(t, s, None))),
|
||||||
key_pat!(Char('g')) => Some(Self::Phrases(PhrasesCommand::Select(0))),
|
key_pat!(Char('g')) => Some(Self::Phrases(PhrasesCommand::Select(0))),
|
||||||
key_pat!(Char('p')) => Some(Self::Put(t, s, Some(state.phrases.phrase().clone()))),
|
key_pat!(Char('p')) => Some(Self::PutClip(t, s, Some(state.phrases.phrase().clone()))),
|
||||||
key_pat!(Char('q')) => { todo!("enqueue") },
|
key_pat!(Char('q')) => Some(Self::EnqueueClip(t, s)),
|
||||||
key_pat!(Delete) => Some(Self::Clip(Clip::Set(t, s, None))),
|
key_pat!(Delete) => Some(Self::Clip(Clip::Set(t, s, None))),
|
||||||
//key_pat!(Char('c')) => Cmd::Clip(Clip::Color(t, s, ItemPalette::random())),
|
//key_pat!(Char('c')) => Cmd::Clip(Clip::Color(t, s, ItemPalette::random())),
|
||||||
//key_pat!(Char('g')) => Cmd::Clip(Clip(Clip::Get(t, s))),
|
//key_pat!(Char('g')) => Cmd::Clip(Clip(Clip::Get(t, s))),
|
||||||
|
|
@ -85,8 +89,8 @@ input_to_command!(ArrangerCommand: <Tui>|state: ArrangerTui, input|{
|
||||||
key_pat!(Char('.')) => Some(Self::Scene(Scene::Swap(s, s + 1))),
|
key_pat!(Char('.')) => Some(Self::Scene(Scene::Swap(s, s + 1))),
|
||||||
key_pat!(Char('<')) => Some(Self::Scene(Scene::Swap(s, s - 1))),
|
key_pat!(Char('<')) => Some(Self::Scene(Scene::Swap(s, s - 1))),
|
||||||
key_pat!(Char('>')) => Some(Self::Scene(Scene::Swap(s, s + 1))),
|
key_pat!(Char('>')) => Some(Self::Scene(Scene::Swap(s, s + 1))),
|
||||||
key_pat!(Char('q')) => Some(Self::Scene(Scene::Play(s))),
|
|
||||||
key_pat!(Char('c')) => Some(Self::Scene(Scene::SetColor(s, ItemPalette::random()))),
|
key_pat!(Char('c')) => Some(Self::Scene(Scene::SetColor(s, ItemPalette::random()))),
|
||||||
|
key_pat!(Char('q')) => Some(Self::EnqueueScene(s)),
|
||||||
key_pat!(Delete) => Some(Self::Scene(Scene::Delete(s))),
|
key_pat!(Delete) => Some(Self::Scene(Scene::Delete(s))),
|
||||||
//key_pat!(Char('c')) => Cmd::Track(Scene::Color(s, ItemPalette::random())),
|
//key_pat!(Char('c')) => Cmd::Track(Scene::Color(s, ItemPalette::random())),
|
||||||
_ => None
|
_ => None
|
||||||
|
|
@ -123,58 +127,75 @@ input_to_command!(ArrangerCommand: <Tui>|state: ArrangerTui, input|{
|
||||||
})?
|
})?
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
command!(|self:ArrangerCommand,state:ArrangerTui|{
|
command!(|self:ArrangerCommand,state:ArrangerTui|match self {
|
||||||
use ArrangerCommand::*;
|
Self::Scene(cmd) => cmd.execute(state)?.map(Self::Scene),
|
||||||
match self {
|
Self::Track(cmd) => cmd.execute(state)?.map(Self::Track),
|
||||||
Scene(cmd) => cmd.execute(state)?.map(Scene),
|
Self::Clip(cmd) => cmd.execute(state)?.map(Self::Clip),
|
||||||
Track(cmd) => cmd.execute(state)?.map(Track),
|
Self::Editor(cmd) => cmd.execute(&mut state.editor)?.map(Self::Editor),
|
||||||
Clip(cmd) => cmd.execute(state)?.map(Clip),
|
Self::Clock(cmd) => cmd.execute(state)?.map(Self::Clock),
|
||||||
Editor(cmd) => cmd.execute(&mut state.editor)?.map(Editor),
|
Self::Zoom(_) => { todo!(); },
|
||||||
Clock(cmd) => cmd.execute(state)?.map(Clock),
|
Self::Select(selected) => {
|
||||||
Zoom(_) => { todo!(); },
|
*state.selected_mut() = selected;
|
||||||
Select(selected) => {
|
None
|
||||||
*state.selected_mut() = selected;
|
},
|
||||||
None
|
Self::Color(palette) => {
|
||||||
},
|
let old = state.color;
|
||||||
Color(palette) => {
|
state.color = palette;
|
||||||
let old = state.color;
|
Some(Self::Color(old))
|
||||||
state.color = palette;
|
},
|
||||||
Some(Color(old))
|
Self::ShowPool(show) => {
|
||||||
},
|
state.show_pool = show;
|
||||||
ShowPool(show) => {
|
None
|
||||||
state.show_pool = show;
|
},
|
||||||
None
|
Self::Phrases(cmd) => {
|
||||||
},
|
let mut default = |cmd: PhrasesCommand|{
|
||||||
Phrases(cmd) => {
|
cmd.execute(&mut state.phrases).map(|x|x.map(Self::Phrases))
|
||||||
let mut default = |cmd: PhrasesCommand|cmd
|
};
|
||||||
.execute(&mut state.phrases)
|
match cmd {
|
||||||
.map(|x|x.map(Phrases));
|
// autoselect: automatically load selected phrase in editor
|
||||||
match cmd {
|
PhrasesCommand::Select(_) => {
|
||||||
// autoselect: automatically load selected phrase in editor
|
let undo = default(cmd)?;
|
||||||
PhrasesCommand::Select(_) => {
|
state.editor.set_phrase(Some(state.phrases.phrase()));
|
||||||
let undo = default(cmd)?;
|
undo
|
||||||
state.editor.set_phrase(Some(state.phrases.phrase()));
|
},
|
||||||
undo
|
// update color in all places simultaneously
|
||||||
},
|
PhrasesCommand::Phrase(PhrasePoolCommand::SetColor(index, _)) => {
|
||||||
// update color in all places simultaneously
|
let undo = default(cmd)?;
|
||||||
PhrasesCommand::Phrase(PhrasePoolCommand::SetColor(index, _)) => {
|
state.editor.set_phrase(Some(state.phrases.phrase()));
|
||||||
let undo = default(cmd)?;
|
undo
|
||||||
state.editor.set_phrase(Some(state.phrases.phrase()));
|
},
|
||||||
undo
|
_ => default(cmd)?
|
||||||
},
|
}
|
||||||
_ => default(cmd)?
|
},
|
||||||
}
|
Self::Undo => { todo!() },
|
||||||
},
|
Self::Redo => { todo!() },
|
||||||
Undo => { todo!() },
|
Self::Clear => { todo!() },
|
||||||
Redo => { todo!() },
|
Self::GetClip(track, scene) => { todo!() },
|
||||||
Clear => { todo!() },
|
Self::PutClip(track, scene, phrase) => {
|
||||||
StopAll => { todo!() },
|
let old = state.scenes[scene].clips[track].clone();
|
||||||
Put(track, scene, phrase) => {
|
state.scenes[scene].clips[track] = phrase;
|
||||||
let old = state.scenes[scene].clips[track].clone();
|
Some(Self::PutClip(track, scene, old))
|
||||||
state.scenes[scene].clips[track] = phrase;
|
},
|
||||||
Some(Put(track, scene, old))
|
Self::EnqueueClip(track, scene) => {
|
||||||
},
|
state.tracks[track].player.enqueue_next(state.scenes[scene].clips[track].as_ref());
|
||||||
}
|
None
|
||||||
|
},
|
||||||
|
Self::EnqueueScene(scene) => {
|
||||||
|
for track in 0..state.tracks.len() {
|
||||||
|
state.tracks[track].player.enqueue_next(state.scenes[scene].clips[track].as_ref());
|
||||||
|
}
|
||||||
|
None
|
||||||
|
},
|
||||||
|
Self::StopTrack(track) => {
|
||||||
|
state.tracks[track].player.enqueue_next(None);
|
||||||
|
None
|
||||||
|
},
|
||||||
|
Self::StopAll => {
|
||||||
|
for track in 0..state.tracks.len() {
|
||||||
|
state.tracks[track].player.enqueue_next(None);
|
||||||
|
}
|
||||||
|
None
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
|
|
||||||
|
|
@ -247,7 +247,9 @@ impl<'a> ArrangerVClips<'a> {
|
||||||
bg = color.light.rgb
|
bg = color.light.rgb
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
add(&Fixed::w(w as u16, Tui::push_x(1, &name.as_str()[0..max_w])))?;
|
add(&Tui::push_x(1, Tui::bg(bg,
|
||||||
|
Tui::push_x(1, Fixed::w(w as u16, &name.as_str()[0..max_w])))
|
||||||
|
))?;
|
||||||
}
|
}
|
||||||
//add(&Background(bg))
|
//add(&Background(bg))
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ use crate::*;
|
||||||
pub enum ArrangerSceneCommand {
|
pub enum ArrangerSceneCommand {
|
||||||
Add,
|
Add,
|
||||||
Delete(usize),
|
Delete(usize),
|
||||||
Play(usize),
|
|
||||||
Swap(usize, usize),
|
Swap(usize, usize),
|
||||||
SetSize(usize),
|
SetSize(usize),
|
||||||
SetZoom(usize),
|
SetZoom(usize),
|
||||||
|
|
|
||||||
|
|
@ -196,9 +196,9 @@ render!(<Tui>|self: PhraseListView<'a>|{
|
||||||
let title_color = TuiTheme::ti1();
|
let title_color = TuiTheme::ti1();
|
||||||
let upper_left = "Pool:";
|
let upper_left = "Pool:";
|
||||||
let upper_right = format!("({})", phrases.len());
|
let upper_right = format!("({})", phrases.len());
|
||||||
let color = ItemPalette::from(Color::Rgb(128,0,0));
|
let color = self.0.phrase().read().unwrap().color;
|
||||||
Tui::bg(bg, lay!(move|add|{
|
Tui::bg(bg, lay!(move|add|{
|
||||||
add(&Fill::wh(Outer(Style::default().fg(color.light.rgb).bg(bg))))?;
|
add(&Fill::wh(Outer(Style::default().fg(color.base.rgb).bg(bg))))?;
|
||||||
//add(&Lozenge(Style::default().bg(border_bg).fg(border_color)))?;
|
//add(&Lozenge(Style::default().bg(border_bg).fg(border_color)))?;
|
||||||
add(&Tui::inset_xy(0, 1, Fill::wh(col!(move|add|match mode {
|
add(&Tui::inset_xy(0, 1, Fill::wh(col!(move|add|match mode {
|
||||||
Some(PhraseListMode::Import(_, ref file_picker)) => add(file_picker),
|
Some(PhraseListMode::Import(_, ref file_picker)) => add(file_picker),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue