wip: p.57, e=81

This commit is contained in:
🪞👃🪞 2024-11-19 00:13:12 +01:00
parent 0964ad3be4
commit 0c94c2af8f
11 changed files with 672 additions and 667 deletions

View file

@ -7,79 +7,6 @@ pub enum TransportCommand {
Playhead(PlayheadCommand),
}
#[derive(Clone, Debug, PartialEq)]
pub enum SequencerCommand {
Focus(FocusCommand),
Undo,
Redo,
Clear,
Clock(ClockCommand),
Playhead(PlayheadCommand),
Phrases(PhrasesCommand),
Editor(PhraseCommand),
}
#[derive(Clone, Debug)]
pub enum ArrangerCommand {
Focus(FocusCommand),
Undo,
Redo,
Clear,
Clock(ClockCommand),
Playhead(PlayheadCommand),
Scene(ArrangerSceneCommand),
Track(ArrangerTrackCommand),
Clip(ArrangerClipCommand),
Select(ArrangerSelection),
Zoom(usize),
Phrases(PhrasePoolCommand),
Editor(PhraseCommand),
EditPhrase(Option<Arc<RwLock<Phrase>>>),
}
#[derive(Clone, PartialEq, Debug)]
pub enum PhrasesCommand {
Select(usize),
Edit(PhrasePoolCommand),
Rename(PhraseRenameCommand),
Length(PhraseLengthCommand),
}
#[derive(Clone, Debug, PartialEq)]
pub enum PhraseRenameCommand {
Begin,
Set(String),
Confirm,
Cancel,
}
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum PhraseLengthCommand {
Begin,
Next,
Prev,
Inc,
Dec,
Set(usize),
Cancel,
}
#[derive(Clone, PartialEq, Debug)]
pub enum PhraseCommand {
// TODO: 1-9 seek markers that by default start every 8th of the phrase
ToggleDirection,
EnterEditMode,
ExitEditMode,
NoteAppend,
NoteSet,
NoteCursorSet(usize),
NoteLengthSet(usize),
NoteScrollSet(usize),
TimeCursorSet(usize),
TimeScrollSet(usize),
TimeZoomSet(usize),
}
impl<T: TransportControl> Command<T> for TransportCommand {
fn execute (self, state: &mut T) -> Perhaps<Self> {
use TransportCommand::{Focus, Clock, Playhead};
@ -97,6 +24,18 @@ impl<T: TransportControl> Command<T> for TransportCommand {
}
}
#[derive(Clone, Debug, PartialEq)]
pub enum SequencerCommand {
Focus(FocusCommand),
Undo,
Redo,
Clear,
Clock(ClockCommand),
Playhead(PlayheadCommand),
Phrases(PhrasesCommand),
Editor(PhraseCommand),
}
impl<T> Command<T> for SequencerCommand
where
T: FocusGrid + PhrasesControl + PhraseControl + ClockApi + PlayheadApi
@ -113,6 +52,24 @@ where
}
}
#[derive(Clone, Debug)]
pub enum ArrangerCommand {
Focus(FocusCommand),
Undo,
Redo,
Clear,
Clock(ClockCommand),
Playhead(PlayheadCommand),
Scene(ArrangerSceneCommand),
Track(ArrangerTrackCommand),
Clip(ArrangerClipCommand),
Select(ArrangerSelection),
Zoom(usize),
Phrases(PhrasePoolCommand),
Editor(PhraseCommand),
EditPhrase(Option<Arc<RwLock<Phrase>>>),
}
impl<T> Command<T> for ArrangerCommand
where
T: FocusGrid + ArrangerControl + HasPhrases + PhraseControl + ClockApi + PlayheadApi
@ -161,6 +118,16 @@ impl<T: ArrangerControl> Command<T> for ArrangerClipCommand {
}
}
#[derive(Clone, PartialEq, Debug)]
pub enum PhrasesCommand {
Select(usize),
Phrase(PhrasePoolCommand),
Rename(PhraseRenameCommand),
Length(PhraseLengthCommand),
MoveUp,
MoveDown,
}
impl<T: PhrasesControl> Command<T> for PhrasesCommand {
fn execute (self, state: &mut T) -> Perhaps<Self> {
use PhraseRenameCommand as Rename;
@ -169,8 +136,8 @@ impl<T: PhrasesControl> Command<T> for PhrasesCommand {
Self::Select(phrase) => {
state.phrase = phrase
},
Self::Edit(command) => {
return Ok(command.execute(&mut state)?.map(Self::Edit))
Self::Phrase(command) => {
return Ok(command.execute(&mut state)?.map(Self::Phrase))
}
Self::Rename(command) => match command {
Rename::Begin => self.phrases_rename_begin(),
@ -185,6 +152,17 @@ impl<T: PhrasesControl> Command<T> for PhrasesCommand {
}
}
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum PhraseLengthCommand {
Begin,
Next,
Prev,
Inc,
Dec,
Set(usize),
Cancel,
}
impl<T: PhrasesControl> Command<T> for PhraseLengthCommand {
fn execute (self, state: &mut T) -> Perhaps<Self> {
use PhraseLengthFocus::*;
@ -229,29 +207,39 @@ impl<T: PhrasesControl> Command<T> for PhraseLengthCommand {
}
}
impl<T: PhrasesControl> Command<T> for PhraseRenameCommand {
#[derive(Clone, Debug, PartialEq)]
pub enum PhraseRenameCommand {
Begin,
Set(String),
Confirm,
Cancel,
}
impl<T> Command<T> for PhraseRenameCommand
where
T: PhrasesControl
{
fn execute (self, state: &mut T) -> Perhaps<Self> {
use PhraseRenameCommand::*;
if let Some(PhrasesMode::Rename(phrase, ref mut old_name)) = state.mode {
if let Some(PhrasesMode::Rename(phrase, ref mut old_name)) = state.phrases_mode() {
match self {
Set(s) => {
state.phrases[phrase].write().unwrap().name = s.into();
state.phrases()[*phrase].write().unwrap().name = s.into();
return Ok(Some(Self::Set(old_name.clone())))
},
Confirm => {
let old_name = old_name.clone();
state.mode = None;
*state.phrases_mode_mut() = None;
return Ok(Some(Self::Set(old_name)))
},
Cancel => {
let mut phrase = state.phrases[phrase].write().unwrap();
phrase.name = old_name.clone();
state.phrases()[*phrase].write().unwrap().name = old_name.clone();
},
_ => unreachable!()
};
Ok(None)
} else if self == Begin {
self.phrases_rename_begin();
self.phrase_rename_begin();
Ok(None)
} else {
unreachable!()
@ -259,7 +247,26 @@ impl<T: PhrasesControl> Command<T> for PhraseRenameCommand {
}
}
impl<T: PhraseControl> Command<T> for PhraseCommand {
#[derive(Clone, PartialEq, Debug)]
pub enum PhraseCommand {
// TODO: 1-9 seek markers that by default start every 8th of the phrase
ToggleDirection,
EnterEditMode,
ExitEditMode,
NoteAppend,
NoteSet,
NoteCursorSet(usize),
NoteLengthSet(usize),
NoteScrollSet(usize),
TimeCursorSet(usize),
TimeScrollSet(usize),
TimeZoomSet(usize),
}
impl<T> Command<T> for PhraseCommand
where
T: PhraseControl + FocusEnter
{
//fn translate (self, state: &PhraseTui<E>) -> Self {
//use PhraseCommand::*;
//match self {
@ -277,10 +284,10 @@ impl<T: PhraseControl> Command<T> for PhraseCommand {
state.mode = !state.mode;
},
EnterEditMode => {
state.entered = true;
state.focus_enter();
},
ExitEditMode => {
state.entered = false;
state.focus_exit();
},
TimeZoomOut => {
let scale = state.time_axis().read().unwrap().scale;
@ -338,14 +345,12 @@ impl<T: PhraseControl> Command<T> for PhraseCommand {
axis.start_inc(3);
axis.point_inc(3);
},
NoteAppend => {
if state.entered {
state.put();
state.time_cursor_advance();
}
NoteAppend => if state.focus_entered() {
state.put();
state.time_cursor_advance();
},
NoteSet => {
if state.entered { state.put(); }
NoteSet => if state.focus_entered() {
state.put();
},
_ => unreachable!()
}