mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
edit from now/next/phrases, pt.1
This commit is contained in:
parent
c0c32c89b7
commit
c93081d061
5 changed files with 39 additions and 30 deletions
|
|
@ -4,7 +4,7 @@ use crate::*;
|
|||
pub struct ArrangerTui {
|
||||
pub jack: Arc<RwLock<JackClient>>,
|
||||
pub clock: ClockModel,
|
||||
pub phrases: PhrasesModel,
|
||||
pub phrases: PhraseListModel,
|
||||
pub tracks: Vec<ArrangerTrack>,
|
||||
pub scenes: Vec<ArrangerScene>,
|
||||
pub name: Arc<RwLock<String>>,
|
||||
|
|
@ -31,7 +31,7 @@ impl TryFrom<&Arc<RwLock<JackClient>>> for ArrangerTui {
|
|||
Ok(Self {
|
||||
jack: jack.clone(),
|
||||
clock: ClockModel::from(&Arc::new(jack.read().unwrap().transport())),
|
||||
phrases: PhrasesModel::default(),
|
||||
phrases: PhraseListModel::default(),
|
||||
editor: PhraseEditorModel::default(),
|
||||
selected: ArrangerSelection::Clip(0, 0),
|
||||
scenes: vec![],
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use crate::*;
|
|||
pub struct SequencerTui {
|
||||
pub jack: Arc<RwLock<JackClient>>,
|
||||
pub clock: ClockModel,
|
||||
pub phrases: PhrasesModel,
|
||||
pub phrases: PhraseListModel,
|
||||
pub player: PhrasePlayerModel,
|
||||
pub editor: PhraseEditorModel,
|
||||
pub size: Measure<Tui>,
|
||||
|
|
@ -23,7 +23,7 @@ impl TryFrom<&Arc<RwLock<JackClient>>> for SequencerTui {
|
|||
let clock = ClockModel::from(&Arc::new(jack.read().unwrap().transport()));
|
||||
Ok(Self {
|
||||
jack: jack.clone(),
|
||||
phrases: PhrasesModel::default(),
|
||||
phrases: PhraseListModel::default(),
|
||||
player: PhrasePlayerModel::from(&clock),
|
||||
editor: PhraseEditorModel::default(),
|
||||
size: Measure::new(),
|
||||
|
|
@ -98,6 +98,7 @@ pub struct SequencerStatusBar {
|
|||
pub(crate) size: String,
|
||||
pub(crate) sr: String,
|
||||
pub(crate) mode: &'static str,
|
||||
pub(crate) help: &'static [(&'static str, &'static str, &'static str)]
|
||||
}
|
||||
|
||||
impl StatusBar for SequencerStatusBar {
|
||||
|
|
@ -130,7 +131,8 @@ impl From<&SequencerTui> for SequencerStatusBar {
|
|||
PhraseEditor => " EDIT MIDI ",
|
||||
PhrasePlay => " TO PLAY ",
|
||||
PhraseNext => " UP NEXT ",
|
||||
}
|
||||
},
|
||||
help: &[]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ macro_rules! impl_has_phrases {
|
|||
}
|
||||
}
|
||||
}
|
||||
impl_has_phrases!(PhrasesModel);
|
||||
impl_has_phrases!(PhraseListModel);
|
||||
impl_has_phrases!(SequencerTui::phrases);
|
||||
impl_has_phrases!(ArrangerTui::phrases);
|
||||
|
||||
|
|
|
|||
|
|
@ -45,38 +45,45 @@ impl InputToCommand<Tui, SequencerTui> for SequencerCommand {
|
|||
|
||||
pub fn to_sequencer_command (state: &SequencerTui, input: &TuiInput) -> Option<SequencerCommand> {
|
||||
use SequencerCommand::*;
|
||||
use PhraseCommand::Show;
|
||||
use ClockCommand::{Play, Pause};
|
||||
use KeyCode::Char;
|
||||
if !state.entered() {
|
||||
return None
|
||||
}
|
||||
Some(match input.event() {
|
||||
key!(Char('e')) => Editor(
|
||||
PhraseCommand::Show(state.phrase_to_edit().clone())
|
||||
),
|
||||
key!(Char(' ')) => Clock(if state.is_stopped() {
|
||||
ClockCommand::Play(None)
|
||||
} else {
|
||||
ClockCommand::Pause(None)
|
||||
}),
|
||||
key!(Shift-Char(' ')) => Clock(if state.is_stopped() {
|
||||
ClockCommand::Play(Some(0))
|
||||
} else {
|
||||
ClockCommand::Pause(Some(0))
|
||||
}),
|
||||
// Edit phrase
|
||||
//key!(Char('e')) => Editor(Show(state.phrase_to_edit().clone())),
|
||||
key!(Char(' ')) => Clock(if state.is_stopped() { Play(None) } else { Pause(None) }),
|
||||
key!(Shift-Char(' ')) => Clock(if state.is_stopped() { Play(Some(0)) } else { Pause(Some(0)) }),
|
||||
_ => match state.focused() {
|
||||
SequencerFocus::Transport(_) => {
|
||||
match TransportCommand::input_to_command(state, input)? {
|
||||
SequencerFocus::Transport(_) => match TransportCommand::input_to_command(state, input)? {
|
||||
TransportCommand::Clock(command) => Clock(command),
|
||||
_ => return None,
|
||||
}
|
||||
},
|
||||
SequencerFocus::PhraseList => Phrases(
|
||||
SequencerFocus::PhrasePlay => match input.event() {
|
||||
key!(Char('e')) => Editor(Show(
|
||||
state.player.play_phrase().as_ref().map(|x|x.1.as_ref()).flatten().map(|x|x.clone())
|
||||
)),
|
||||
_ => return None,
|
||||
},
|
||||
SequencerFocus::PhraseNext => match input.event() {
|
||||
key!(Char('e')) => Editor(Show(
|
||||
state.player.next_phrase().as_ref().map(|x|x.1.as_ref()).flatten().map(|x|x.clone())
|
||||
)),
|
||||
_ => return None,
|
||||
},
|
||||
SequencerFocus::PhraseList => match input.event() {
|
||||
key!(Char('e')) => Editor(Show(
|
||||
Some(state.phrases.phrases[state.phrases.phrase.load(Ordering::Relaxed)].clone())
|
||||
)),
|
||||
_ => Phrases(
|
||||
PhrasesCommand::input_to_command(state, input)?
|
||||
),
|
||||
)
|
||||
},
|
||||
SequencerFocus::PhraseEditor => Editor(
|
||||
PhraseCommand::input_to_command(state, input)?
|
||||
),
|
||||
_ => todo!()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::*;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PhrasesModel {
|
||||
pub struct PhraseListModel {
|
||||
/// Collection of phrases
|
||||
pub(crate) phrases: Vec<Arc<RwLock<Phrase>>>,
|
||||
/// Selected phrase
|
||||
|
|
@ -12,7 +12,7 @@ pub struct PhrasesModel {
|
|||
pub(crate) mode: Option<PhrasesMode>,
|
||||
}
|
||||
|
||||
impl Default for PhrasesModel {
|
||||
impl Default for PhraseListModel {
|
||||
fn default () -> Self {
|
||||
Self {
|
||||
phrases: vec![RwLock::new(Phrase::default()).into()],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue