mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 20:56:43 +01:00
wip: focus refactor, e13
This commit is contained in:
parent
364769a2e0
commit
6127aa4b30
9 changed files with 110 additions and 65 deletions
|
|
@ -6,7 +6,7 @@ impl<T: TransportControl> InputToCommand<Tui, T> for TransportCommand {
|
|||
use ClockCommand::{SetBpm, SetQuant, SetSync};
|
||||
use TransportFocus as Focused;
|
||||
use TransportCommand::{Focus, Clock};
|
||||
let focused = state.transport_focused();
|
||||
let focused = state.transport_focused().unwrap();
|
||||
Some(match input.event() {
|
||||
key!(Left) => Focus(FocusCommand::Prev),
|
||||
key!(Right) => Focus(FocusCommand::Next),
|
||||
|
|
@ -47,39 +47,35 @@ impl<T: TransportControl> InputToCommand<Tui, T> for TransportCommand {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> InputToCommand<Tui, T> for SequencerCommand
|
||||
where
|
||||
T: SequencerControl + TransportControl + PhrasesControl + PhraseEditorControl
|
||||
+ HasFocus<Item = SequencerFocus>
|
||||
+ FocusGrid<Item = SequencerFocus>
|
||||
{
|
||||
fn input_to_command (state: &T, input: &TuiInput) -> Option<Self> {
|
||||
impl InputToCommand<Tui, SequencerTui> for SequencerCommand {
|
||||
fn input_to_command (state: &SequencerTui, input: &TuiInput) -> Option<Self> {
|
||||
use FocusCommand::*;
|
||||
use SequencerCommand::*;
|
||||
match input.event() {
|
||||
key!(KeyCode::Tab) => Some(Self::Focus(Next)),
|
||||
key!(Shift-KeyCode::Tab) => Some(Self::Focus(Prev)),
|
||||
key!(KeyCode::BackTab) => Some(Self::Focus(Prev)),
|
||||
key!(Shift-KeyCode::BackTab) => Some(Self::Focus(Prev)),
|
||||
key!(KeyCode::Up) => Some(Self::Focus(Up)),
|
||||
key!(KeyCode::Down) => Some(Self::Focus(Down)),
|
||||
key!(KeyCode::Left) => Some(Self::Focus(Left)),
|
||||
key!(KeyCode::Right) => Some(Self::Focus(Right)),
|
||||
_ => Some(match state.focused() {
|
||||
SequencerFocus::Transport => {
|
||||
Some(match input.event() {
|
||||
key!(KeyCode::Tab) => Self::Focus(Next),
|
||||
key!(Shift-KeyCode::Tab) => Self::Focus(Prev),
|
||||
key!(KeyCode::BackTab) => Self::Focus(Prev),
|
||||
key!(Shift-KeyCode::BackTab) => Self::Focus(Prev),
|
||||
key!(KeyCode::Up) => Self::Focus(Up),
|
||||
key!(KeyCode::Down) => Self::Focus(Down),
|
||||
key!(KeyCode::Left) => Self::Focus(Left),
|
||||
key!(KeyCode::Right) => Self::Focus(Right),
|
||||
_ => match state.focused() {
|
||||
AppFocus::Menu => todo!(),
|
||||
AppFocus::Content(SequencerFocus::Transport(_)) => {
|
||||
use TransportCommand::{Clock, Focus};
|
||||
match TransportCommand::input_to_command(state, input)? {
|
||||
Clock(command) => { todo!() },
|
||||
Focus(command) => { todo!() },
|
||||
Clock(command) => { todo!() },
|
||||
Focus(command) => { todo!() },
|
||||
}
|
||||
},
|
||||
SequencerFocus::Phrases =>
|
||||
AppFocus::Content(SequencerFocus::Phrases) =>
|
||||
Phrases(PhrasesCommand::input_to_command(state, input)?),
|
||||
SequencerFocus::PhraseEditor =>
|
||||
AppFocus::Content(SequencerFocus::PhraseEditor) =>
|
||||
Editor(PhraseCommand::input_to_command(state, input)?),
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -100,22 +96,22 @@ impl InputToCommand<Tui, ArrangerTui> for ArrangerCommand {
|
|||
key!(KeyCode::Esc) => Self::Focus(Exit),
|
||||
key!(KeyCode::Char(' ')) => Self::Clock(ClockCommand::Play(None)),
|
||||
_ => match state.focused() {
|
||||
ArrangerFocus::Menu => { todo!() },
|
||||
ArrangerFocus::Transport => {
|
||||
AppFocus::Menu => todo!(),
|
||||
AppFocus::Content(ArrangerFocus::Transport(_)) => {
|
||||
use TransportCommand::{Clock, Focus};
|
||||
match TransportCommand::input_to_command(state, input)? {
|
||||
Clock(command) => { todo!() },
|
||||
Focus(command) => { todo!() }
|
||||
}
|
||||
},
|
||||
ArrangerFocus::PhraseEditor => Editor(
|
||||
AppFocus::Content(ArrangerFocus::PhraseEditor) => Editor(
|
||||
PhraseCommand::input_to_command(state, input)?
|
||||
),
|
||||
ArrangerFocus::Phrases => match input.event() {
|
||||
AppFocus::Content(ArrangerFocus::Phrases) => match input.event() {
|
||||
key!(KeyCode::Char('e')) => EditPhrase(state.phrase_editing().clone()),
|
||||
_ => Phrases(PhrasesCommand::input_to_command(state, input)?)
|
||||
},
|
||||
ArrangerFocus::Arranger => {
|
||||
AppFocus::Content(ArrangerFocus::Arranger) => {
|
||||
use ArrangerSelection as Select;
|
||||
use ArrangerTrackCommand as Track;
|
||||
use ArrangerClipCommand as Clip;
|
||||
|
|
@ -348,7 +344,7 @@ impl<T: PhrasesControl> InputToCommand<Tui, T> for PhraseRenameCommand {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: PhraseEditorControl> InputToCommand<Tui, T> for PhraseCommand {
|
||||
impl<T: PhraseEditorControl + HasEnter> InputToCommand<Tui, T> for PhraseCommand {
|
||||
fn input_to_command (state: &T, from: &TuiInput) -> Option<Self> {
|
||||
use PhraseCommand::*;
|
||||
Some(match from.event() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue