mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 12:46:42 +01:00
wip(p60,e90): impl macros
This commit is contained in:
parent
f4a4b08c8a
commit
9d4fcaa32b
17 changed files with 748 additions and 1083 deletions
|
|
@ -2,7 +2,9 @@ use crate::*;
|
|||
|
||||
impl<T> InputToCommand<Tui, T> for TransportCommand
|
||||
where
|
||||
T: TransportControl + HasFocus<Item = TransportFocus>
|
||||
T: TransportControl
|
||||
+ HasFocus<Item = TransportFocus>
|
||||
+ FocusEnter<Item = TransportFocus>
|
||||
{
|
||||
fn input_to_command (state: &T, input: &TuiInput) -> Option<Self> {
|
||||
use KeyCode::Char;
|
||||
|
|
@ -53,7 +55,9 @@ where
|
|||
impl<T> InputToCommand<Tui, T> for SequencerCommand
|
||||
where
|
||||
T: SequencerControl + TransportControl + PhrasesControl + PhraseControl + PlayheadApi
|
||||
+ HasFocus<Item = SequencerFocus> + FocusGrid<Item = SequencerFocus>
|
||||
+ HasFocus<Item = SequencerFocus>
|
||||
+ FocusGrid<Item = SequencerFocus>
|
||||
+ FocusEnter<Item = SequencerFocus>
|
||||
{
|
||||
fn input_to_command (state: &T, input: &TuiInput) -> Option<Self> {
|
||||
use FocusCommand::*;
|
||||
|
|
@ -91,12 +95,8 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> InputToCommand<Tui, T> for ArrangerCommand
|
||||
where
|
||||
T: ArrangerControl + TransportControl + PhrasesControl + PhraseControl + PlayheadApi
|
||||
+ HasFocus<Item = ArrangerFocus> + FocusGrid<Item = ArrangerFocus>
|
||||
{
|
||||
fn input_to_command (state: &T, input: &TuiInput) -> Option<Self> {
|
||||
impl InputToCommand<Tui, ArrangerTui> for ArrangerCommand {
|
||||
fn input_to_command (state: &ArrangerCommand, input: &TuiInput) -> Option<Self> {
|
||||
use FocusCommand::*;
|
||||
use ArrangerCommand::*;
|
||||
Some(match input.event() {
|
||||
|
|
@ -240,7 +240,12 @@ where
|
|||
Select::Clip(t, s) => Clip(Clip::Set(t, s, None)),
|
||||
},
|
||||
|
||||
key!(KeyCode::Char('c')) => Clip(Clip::RandomColor),
|
||||
key!(KeyCode::Char('c')) => match state.selected() {
|
||||
Select::Mix => Color(ItemColor::random()),
|
||||
Select::Track(t) => Track(Track::Delete(t)),
|
||||
Select::Scene(s) => Scene(Scene::Delete(s)),
|
||||
Select::Clip(t, s) => Clip(Clip::Set(t, s, None)),
|
||||
},
|
||||
|
||||
key!(KeyCode::Char('s')) => match state.selected() {
|
||||
Select::Clip(t, s) => Clip(Clip::Set(t, s, None)),
|
||||
|
|
@ -279,7 +284,7 @@ impl<T: PhrasesControl> InputToCommand<Tui, T> for PhrasesCommand {
|
|||
key!(KeyCode::Down) => Some(Self::Select(0)),
|
||||
key!(KeyCode::Char(',')) => {
|
||||
if index > 1 {
|
||||
*state.phrase_index_mut() -= 1;
|
||||
state.set_phrase_index(state.phrase_index().saturating_sub(1));
|
||||
Some(Self::Phrase(Phrase::Swap(index - 1, index)))
|
||||
} else {
|
||||
None
|
||||
|
|
@ -287,7 +292,7 @@ impl<T: PhrasesControl> InputToCommand<Tui, T> for PhrasesCommand {
|
|||
},
|
||||
key!(KeyCode::Char('.')) => {
|
||||
if index < count.saturating_sub(1) {
|
||||
*state.phrase_index_mut() += 1;
|
||||
state.set_phrase_index(state.phrase_index() + 1);
|
||||
Some(Self::Phrase(Phrase::Swap(index + 1, index)))
|
||||
} else {
|
||||
None
|
||||
|
|
@ -295,7 +300,7 @@ impl<T: PhrasesControl> InputToCommand<Tui, T> for PhrasesCommand {
|
|||
},
|
||||
key!(KeyCode::Delete) => {
|
||||
if index > 0 {
|
||||
*state.phrase_index_mut() = index.min(count.saturating_sub(1));
|
||||
state.set_phrase_index(index.min(count.saturating_sub(1)));
|
||||
Some(Self::Phrase(Phrase::Delete(index)))
|
||||
} else {
|
||||
None
|
||||
|
|
@ -362,39 +367,47 @@ impl<T: PhrasesControl> InputToCommand<Tui, T> for PhraseRenameCommand {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: PhraseControl> InputToCommand<Tui, T> for PhraseCommand {
|
||||
impl<T> InputToCommand<Tui, T> for PhraseCommand
|
||||
where
|
||||
T: PhraseControl + FocusEnter
|
||||
{
|
||||
fn input_to_command (state: &T, from: &TuiInput) -> Option<Self> {
|
||||
use PhraseCommand::*;
|
||||
Some(match from.event() {
|
||||
key!(KeyCode::Char('`')) => ToggleDirection,
|
||||
key!(KeyCode::Enter) => EnterEditMode,
|
||||
key!(KeyCode::Esc) => ExitEditMode,
|
||||
key!(KeyCode::Char('[')) => NoteLengthSet(0),
|
||||
key!(KeyCode::Char(']')) => NoteLengthSet(0),
|
||||
key!(KeyCode::Char('a')) => NoteAppend,
|
||||
key!(KeyCode::Char('s')) => NoteSet,
|
||||
key!(KeyCode::Char('-')) => TimeZoomSet(0),
|
||||
key!(KeyCode::Char('_')) => TimeZoomSet(0),
|
||||
key!(KeyCode::Char('=')) => TimeZoomSet(0),
|
||||
key!(KeyCode::Char('+')) => TimeZoomSet(0),
|
||||
key!(KeyCode::PageUp) => NoteScrollSet(0),
|
||||
key!(KeyCode::PageDown) => NoteScrollSet(0),
|
||||
|
||||
key!(KeyCode::Up) => match state.phrase_entered() {
|
||||
true => NoteCursorSet(0),
|
||||
false => NoteScrollSet(0),
|
||||
key!(KeyCode::Char('[')) => NoteLengthSet(prev_note_length(state.note_len())),
|
||||
key!(KeyCode::Char(']')) => NoteLengthSet(next_note_length(state.note_len())),
|
||||
key!(KeyCode::Char('-')) => TimeZoomSet(next_note_length(state.time_axis().read().unwrap().scale)),
|
||||
key!(KeyCode::Char('_')) => TimeZoomSet(next_note_length(state.time_axis().read().unwrap().scale)),
|
||||
key!(KeyCode::Char('=')) => TimeZoomSet(prev_note_length(state.time_axis().read().unwrap().scale)),
|
||||
key!(KeyCode::Char('+')) => TimeZoomSet(prev_note_length(state.time_axis().read().unwrap().scale)),
|
||||
key!(KeyCode::Up) => match state.phrase_entered() {
|
||||
true => NoteCursorSet(state.note_axis().write().unwrap().point_plus(1)),
|
||||
false => NoteScrollSet(state.note_axis().write().unwrap().start_plus(1)),
|
||||
},
|
||||
key!(KeyCode::Down) => match state.phrase_entered() {
|
||||
true => NoteCursorSet(0),
|
||||
false => NoteScrollSet(0),
|
||||
key!(KeyCode::Down) => match state.phrase_entered() {
|
||||
true => NoteCursorSet(state.note_axis().write().unwrap().point_minus(1)),
|
||||
false => NoteScrollSet(state.note_axis().write().unwrap().start_minus(1)),
|
||||
},
|
||||
key!(KeyCode::Left) => match state.phrase_entered() {
|
||||
true => TimeCursorSet(0),
|
||||
false => TimeScrollSet(0),
|
||||
key!(KeyCode::PageUp) => match state.phrase_entered() {
|
||||
true => NoteCursorSet(state.note_axis().write().unwrap().point_plus(3)),
|
||||
false => NoteScrollSet(state.note_axis().write().unwrap().start_plus(3)),
|
||||
},
|
||||
key!(KeyCode::Right) => match state.phrase_entered() {
|
||||
true => TimeCursorSet(0),
|
||||
false => TimeScrollSet(0),
|
||||
key!(KeyCode::PageDown) => match state.phrase_entered() {
|
||||
true => NoteCursorSet(state.note_axis().write().unwrap().point_minus(3)),
|
||||
false => NoteScrollSet(state.note_axis().write().unwrap().start_minus(3)),
|
||||
},
|
||||
key!(KeyCode::Left) => match state.phrase_entered() {
|
||||
true => TimeCursorSet(state.note_axis().write().unwrap().point_minus(1)),
|
||||
false => TimeScrollSet(state.note_axis().write().unwrap().start_minus(1)),
|
||||
},
|
||||
key!(KeyCode::Right) => match state.phrase_entered() {
|
||||
true => TimeCursorSet(state.note_axis().write().unwrap().point_plus(1)),
|
||||
false => TimeScrollSet(state.note_axis().write().unwrap().start_plus(1)),
|
||||
},
|
||||
_ => return None
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue