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 struct ArrangerTui {
|
||||||
pub jack: Arc<RwLock<JackClient>>,
|
pub jack: Arc<RwLock<JackClient>>,
|
||||||
pub clock: ClockModel,
|
pub clock: ClockModel,
|
||||||
pub phrases: PhrasesModel,
|
pub phrases: PhraseListModel,
|
||||||
pub tracks: Vec<ArrangerTrack>,
|
pub tracks: Vec<ArrangerTrack>,
|
||||||
pub scenes: Vec<ArrangerScene>,
|
pub scenes: Vec<ArrangerScene>,
|
||||||
pub name: Arc<RwLock<String>>,
|
pub name: Arc<RwLock<String>>,
|
||||||
|
|
@ -31,7 +31,7 @@ impl TryFrom<&Arc<RwLock<JackClient>>> for ArrangerTui {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
jack: jack.clone(),
|
jack: jack.clone(),
|
||||||
clock: ClockModel::from(&Arc::new(jack.read().unwrap().transport())),
|
clock: ClockModel::from(&Arc::new(jack.read().unwrap().transport())),
|
||||||
phrases: PhrasesModel::default(),
|
phrases: PhraseListModel::default(),
|
||||||
editor: PhraseEditorModel::default(),
|
editor: PhraseEditorModel::default(),
|
||||||
selected: ArrangerSelection::Clip(0, 0),
|
selected: ArrangerSelection::Clip(0, 0),
|
||||||
scenes: vec![],
|
scenes: vec![],
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use crate::*;
|
||||||
pub struct SequencerTui {
|
pub struct SequencerTui {
|
||||||
pub jack: Arc<RwLock<JackClient>>,
|
pub jack: Arc<RwLock<JackClient>>,
|
||||||
pub clock: ClockModel,
|
pub clock: ClockModel,
|
||||||
pub phrases: PhrasesModel,
|
pub phrases: PhraseListModel,
|
||||||
pub player: PhrasePlayerModel,
|
pub player: PhrasePlayerModel,
|
||||||
pub editor: PhraseEditorModel,
|
pub editor: PhraseEditorModel,
|
||||||
pub size: Measure<Tui>,
|
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()));
|
let clock = ClockModel::from(&Arc::new(jack.read().unwrap().transport()));
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
jack: jack.clone(),
|
jack: jack.clone(),
|
||||||
phrases: PhrasesModel::default(),
|
phrases: PhraseListModel::default(),
|
||||||
player: PhrasePlayerModel::from(&clock),
|
player: PhrasePlayerModel::from(&clock),
|
||||||
editor: PhraseEditorModel::default(),
|
editor: PhraseEditorModel::default(),
|
||||||
size: Measure::new(),
|
size: Measure::new(),
|
||||||
|
|
@ -98,6 +98,7 @@ pub struct SequencerStatusBar {
|
||||||
pub(crate) size: String,
|
pub(crate) size: String,
|
||||||
pub(crate) sr: String,
|
pub(crate) sr: String,
|
||||||
pub(crate) mode: &'static str,
|
pub(crate) mode: &'static str,
|
||||||
|
pub(crate) help: &'static [(&'static str, &'static str, &'static str)]
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StatusBar for SequencerStatusBar {
|
impl StatusBar for SequencerStatusBar {
|
||||||
|
|
@ -130,7 +131,8 @@ impl From<&SequencerTui> for SequencerStatusBar {
|
||||||
PhraseEditor => " EDIT MIDI ",
|
PhraseEditor => " EDIT MIDI ",
|
||||||
PhrasePlay => " TO PLAY ",
|
PhrasePlay => " TO PLAY ",
|
||||||
PhraseNext => " UP NEXT ",
|
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!(SequencerTui::phrases);
|
||||||
impl_has_phrases!(ArrangerTui::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> {
|
pub fn to_sequencer_command (state: &SequencerTui, input: &TuiInput) -> Option<SequencerCommand> {
|
||||||
use SequencerCommand::*;
|
use SequencerCommand::*;
|
||||||
|
use PhraseCommand::Show;
|
||||||
|
use ClockCommand::{Play, Pause};
|
||||||
use KeyCode::Char;
|
use KeyCode::Char;
|
||||||
if !state.entered() {
|
if !state.entered() {
|
||||||
return None
|
return None
|
||||||
}
|
}
|
||||||
Some(match input.event() {
|
Some(match input.event() {
|
||||||
key!(Char('e')) => Editor(
|
// Edit phrase
|
||||||
PhraseCommand::Show(state.phrase_to_edit().clone())
|
//key!(Char('e')) => Editor(Show(state.phrase_to_edit().clone())),
|
||||||
),
|
key!(Char(' ')) => Clock(if state.is_stopped() { Play(None) } else { Pause(None) }),
|
||||||
key!(Char(' ')) => Clock(if state.is_stopped() {
|
key!(Shift-Char(' ')) => Clock(if state.is_stopped() { Play(Some(0)) } else { Pause(Some(0)) }),
|
||||||
ClockCommand::Play(None)
|
|
||||||
} else {
|
|
||||||
ClockCommand::Pause(None)
|
|
||||||
}),
|
|
||||||
key!(Shift-Char(' ')) => Clock(if state.is_stopped() {
|
|
||||||
ClockCommand::Play(Some(0))
|
|
||||||
} else {
|
|
||||||
ClockCommand::Pause(Some(0))
|
|
||||||
}),
|
|
||||||
_ => match state.focused() {
|
_ => match state.focused() {
|
||||||
SequencerFocus::Transport(_) => {
|
SequencerFocus::Transport(_) => match TransportCommand::input_to_command(state, input)? {
|
||||||
match TransportCommand::input_to_command(state, input)? {
|
TransportCommand::Clock(command) => Clock(command),
|
||||||
TransportCommand::Clock(command) => Clock(command),
|
_ => return None,
|
||||||
_ => return None,
|
},
|
||||||
}
|
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::PhraseList => Phrases(
|
|
||||||
PhrasesCommand::input_to_command(state, input)?
|
|
||||||
),
|
|
||||||
SequencerFocus::PhraseEditor => Editor(
|
SequencerFocus::PhraseEditor => Editor(
|
||||||
PhraseCommand::input_to_command(state, input)?
|
PhraseCommand::input_to_command(state, input)?
|
||||||
),
|
),
|
||||||
_ => todo!()
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct PhrasesModel {
|
pub struct PhraseListModel {
|
||||||
/// Collection of phrases
|
/// Collection of phrases
|
||||||
pub(crate) phrases: Vec<Arc<RwLock<Phrase>>>,
|
pub(crate) phrases: Vec<Arc<RwLock<Phrase>>>,
|
||||||
/// Selected phrase
|
/// Selected phrase
|
||||||
|
|
@ -12,7 +12,7 @@ pub struct PhrasesModel {
|
||||||
pub(crate) mode: Option<PhrasesMode>,
|
pub(crate) mode: Option<PhrasesMode>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for PhrasesModel {
|
impl Default for PhraseListModel {
|
||||||
fn default () -> Self {
|
fn default () -> Self {
|
||||||
Self {
|
Self {
|
||||||
phrases: vec![RwLock::new(Phrase::default()).into()],
|
phrases: vec![RwLock::new(Phrase::default()).into()],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue