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,
|
||||
Redo,
|
||||
Clear,
|
||||
StopAll,
|
||||
Color(ItemPalette),
|
||||
Clock(ClockCommand),
|
||||
Scene(ArrangerSceneCommand),
|
||||
|
|
@ -17,7 +16,12 @@ use KeyCode::{Char, Delete, Tab};
|
|||
Phrases(PhrasesCommand),
|
||||
Editor(PhraseCommand),
|
||||
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|{
|
||||
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('g')) => Some(Self::Phrases(PhrasesCommand::Select(0))),
|
||||
key_pat!(Char('p')) => Some(Self::Put(t, s, Some(state.phrases.phrase().clone()))),
|
||||
key_pat!(Char('q')) => { todo!("enqueue") },
|
||||
key_pat!(Char('p')) => Some(Self::PutClip(t, s, Some(state.phrases.phrase().clone()))),
|
||||
key_pat!(Char('q')) => Some(Self::EnqueueClip(t, s)),
|
||||
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('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('q')) => Some(Self::Scene(Scene::Play(s))),
|
||||
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!(Char('c')) => Cmd::Track(Scene::Color(s, ItemPalette::random())),
|
||||
_ => None
|
||||
|
|
@ -123,32 +127,30 @@ input_to_command!(ArrangerCommand: <Tui>|state: ArrangerTui, input|{
|
|||
})?
|
||||
}
|
||||
});
|
||||
command!(|self:ArrangerCommand,state:ArrangerTui|{
|
||||
use ArrangerCommand::*;
|
||||
match self {
|
||||
Scene(cmd) => cmd.execute(state)?.map(Scene),
|
||||
Track(cmd) => cmd.execute(state)?.map(Track),
|
||||
Clip(cmd) => cmd.execute(state)?.map(Clip),
|
||||
Editor(cmd) => cmd.execute(&mut state.editor)?.map(Editor),
|
||||
Clock(cmd) => cmd.execute(state)?.map(Clock),
|
||||
Zoom(_) => { todo!(); },
|
||||
Select(selected) => {
|
||||
command!(|self:ArrangerCommand,state:ArrangerTui|match self {
|
||||
Self::Scene(cmd) => cmd.execute(state)?.map(Self::Scene),
|
||||
Self::Track(cmd) => cmd.execute(state)?.map(Self::Track),
|
||||
Self::Clip(cmd) => cmd.execute(state)?.map(Self::Clip),
|
||||
Self::Editor(cmd) => cmd.execute(&mut state.editor)?.map(Self::Editor),
|
||||
Self::Clock(cmd) => cmd.execute(state)?.map(Self::Clock),
|
||||
Self::Zoom(_) => { todo!(); },
|
||||
Self::Select(selected) => {
|
||||
*state.selected_mut() = selected;
|
||||
None
|
||||
},
|
||||
Color(palette) => {
|
||||
Self::Color(palette) => {
|
||||
let old = state.color;
|
||||
state.color = palette;
|
||||
Some(Color(old))
|
||||
Some(Self::Color(old))
|
||||
},
|
||||
ShowPool(show) => {
|
||||
Self::ShowPool(show) => {
|
||||
state.show_pool = show;
|
||||
None
|
||||
},
|
||||
Phrases(cmd) => {
|
||||
let mut default = |cmd: PhrasesCommand|cmd
|
||||
.execute(&mut state.phrases)
|
||||
.map(|x|x.map(Phrases));
|
||||
Self::Phrases(cmd) => {
|
||||
let mut default = |cmd: PhrasesCommand|{
|
||||
cmd.execute(&mut state.phrases).map(|x|x.map(Self::Phrases))
|
||||
};
|
||||
match cmd {
|
||||
// autoselect: automatically load selected phrase in editor
|
||||
PhrasesCommand::Select(_) => {
|
||||
|
|
@ -165,16 +167,35 @@ command!(|self:ArrangerCommand,state:ArrangerTui|{
|
|||
_ => default(cmd)?
|
||||
}
|
||||
},
|
||||
Undo => { todo!() },
|
||||
Redo => { todo!() },
|
||||
Clear => { todo!() },
|
||||
StopAll => { todo!() },
|
||||
Put(track, scene, phrase) => {
|
||||
Self::Undo => { todo!() },
|
||||
Self::Redo => { todo!() },
|
||||
Self::Clear => { todo!() },
|
||||
Self::GetClip(track, scene) => { todo!() },
|
||||
Self::PutClip(track, scene, phrase) => {
|
||||
let old = state.scenes[scene].clips[track].clone();
|
||||
state.scenes[scene].clips[track] = phrase;
|
||||
Some(Put(track, scene, old))
|
||||
Some(Self::PutClip(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)]
|
||||
|
|
|
|||
|
|
@ -247,7 +247,9 @@ impl<'a> ArrangerVClips<'a> {
|
|||
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))
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ use crate::*;
|
|||
pub enum ArrangerSceneCommand {
|
||||
Add,
|
||||
Delete(usize),
|
||||
Play(usize),
|
||||
Swap(usize, usize),
|
||||
SetSize(usize),
|
||||
SetZoom(usize),
|
||||
|
|
|
|||
|
|
@ -196,9 +196,9 @@ render!(<Tui>|self: PhraseListView<'a>|{
|
|||
let title_color = TuiTheme::ti1();
|
||||
let upper_left = "Pool:";
|
||||
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|{
|
||||
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(&Tui::inset_xy(0, 1, Fill::wh(col!(move|add|match mode {
|
||||
Some(PhraseListMode::Import(_, ref file_picker)) => add(file_picker),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue