wip(p61,e38)

This commit is contained in:
🪞👃🪞 2024-11-21 00:25:54 +01:00
parent 9d4fcaa32b
commit 76da19d9c6
12 changed files with 172 additions and 141 deletions

View file

@ -38,7 +38,7 @@ pub enum SequencerCommand {
impl<T> Command<T> for SequencerCommand
where
T: PhrasesControl + PhraseControl + PlayheadApi
T: PhrasesControl + PhraseEditorControl + PlayheadApi
+ FocusGrid<Item = SequencerFocus> + FocusEnter<Item = SequencerFocus>
{
fn execute (self, state: &mut T) -> Perhaps<Self> {
@ -93,9 +93,10 @@ impl Command<ArrangerTui> for ArrangerCommand {
None
},
EditPhrase(phrase) => {
state.show_phrase(phrase);
state.edit_phrase(&phrase);
None
}
},
_ => { todo!() }
})
}
}
@ -185,7 +186,7 @@ impl<T: PhrasesControl> Command<T> for PhraseLengthCommand {
Tick => { *length = length.saturating_sub(1) },
},
Self::Set(length) => {
let mut phrase = state.phrases[phrase].write().unwrap();
let mut phrase = state.phrases()[*phrase].write().unwrap();
let old_length = phrase.length;
phrase.length = length;
*mode = None;
@ -217,10 +218,13 @@ where
{
fn execute (self, state: &mut T) -> Perhaps<Self> {
use PhraseRenameCommand::*;
if let Some(PhrasesMode::Rename(phrase, ref mut old_name)) = state.phrases_mode_mut() {
if let Some(PhrasesMode::Rename(
phrase,
ref mut old_name
)) = state.phrases_mode_mut().clone() {
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 => {
@ -229,7 +233,7 @@ where
return Ok(Some(Self::Set(old_name)))
},
Cancel => {
state.phrases()[*phrase].write().unwrap().name = old_name.clone();
state.phrases()[phrase].write().unwrap().name = old_name.clone();
},
_ => unreachable!()
};
@ -251,17 +255,17 @@ pub enum PhraseCommand {
ExitEditMode,
NoteAppend,
NoteSet,
NoteCursorSet(usize),
NoteCursorSet(Option<usize>),
NoteLengthSet(usize),
NoteScrollSet(usize),
TimeCursorSet(usize),
TimeCursorSet(Option<usize>),
TimeScrollSet(usize),
TimeZoomSet(usize),
}
impl<T> Command<T> for PhraseCommand
where
T: PhraseControl + FocusEnter
T: PhraseEditorControl + FocusEnter
{
fn execute (self, state: &mut T) -> Perhaps<Self> {
use PhraseCommand::*;
@ -270,24 +274,28 @@ where
EnterEditMode => { state.focus_enter(); None },
ExitEditMode => { state.focus_exit(); None },
NoteAppend => {
if state.phrase_entered() {
if state.phrase_editor_entered() {
state.put_note();
state.time_cursor_advance();
}
None
},
NoteSet => { if state.phrase_entered() { state.put_note(); } None },
NoteSet => { if state.phrase_editor_entered() { state.put_note(); } None },
TimeCursorSet(time) => { state.time_axis().write().unwrap().point_set(time); None },
TimeScrollSet(time) => { state.time_axis().write().unwrap().start_set(time); None },
TimeZoomSet(zoom) => { state.time_axis().write().unwrap().scale_set(zoom); None },
NoteScrollSet(note) => { state.note_axis().write().unwrap().start_set(note); None },
NoteLengthSet(time) => { *state.note_len_mut() = time; None },
NoteCursorSet(note) => {
let axis = state.note_axis().write().unwrap();
let mut axis = state.note_axis().write().unwrap();
axis.point_set(note);
if let Some(point) = axis.point {
if point > 73 { axis.point = Some(73); }
if point < axis.start { axis.start = (point / 2) * 2; }
if point > 73 {
axis.point = Some(73);
}
if point < axis.start {
axis.start = (point / 2) * 2;
}
}
None
},