mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 20:56:43 +01:00
implement sequencer focus; auto update_focus
This commit is contained in:
parent
9f15f8fff9
commit
3bf475d15e
8 changed files with 119 additions and 160 deletions
|
|
@ -28,15 +28,6 @@ impl Content for Arranger<Tui> {
|
|||
/// Handle top-level events in standalone arranger.
|
||||
impl Handle<Tui> for Arranger<Tui> {
|
||||
fn handle (&mut self, from: &TuiInput) -> Perhaps<bool> {
|
||||
let update_focus = |arranger: &mut Self| {
|
||||
let focused = *arranger.focused();
|
||||
arranger.transport.as_ref().map(|transport|{
|
||||
transport.write().unwrap().focused = focused == ArrangerFocus::Transport
|
||||
});
|
||||
arranger.arrangement.focused = focused == ArrangerFocus::Arrangement;
|
||||
arranger.phrases.write().unwrap().focused = focused == ArrangerFocus::PhrasePool;
|
||||
arranger.editor.focused = focused == ArrangerFocus::PhraseEditor;
|
||||
};
|
||||
if !match self.focused() {
|
||||
ArrangerFocus::Transport => self.transport.handle(from)?,
|
||||
ArrangerFocus::Arrangement => self.arrangement.handle(from)?,
|
||||
|
|
@ -45,15 +36,15 @@ impl Handle<Tui> for Arranger<Tui> {
|
|||
}.unwrap_or(false) {
|
||||
match from.event() {
|
||||
// Tab navigation
|
||||
key!(KeyCode::Tab) => { self.focus_next(); update_focus(self); },
|
||||
key!(Shift-KeyCode::Tab) => { self.focus_prev(); update_focus(self); },
|
||||
key!(KeyCode::BackTab) => { self.focus_prev(); update_focus(self); },
|
||||
key!(Shift-KeyCode::BackTab) => { self.focus_prev(); update_focus(self); },
|
||||
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(); },
|
||||
// Directional navigation
|
||||
key!(KeyCode::Up) => { self.focus_up(); update_focus(self); },
|
||||
key!(KeyCode::Down) => { self.focus_down(); update_focus(self); },
|
||||
key!(KeyCode::Left) => { self.focus_left(); update_focus(self); },
|
||||
key!(KeyCode::Right) => { self.focus_right(); update_focus(self); },
|
||||
key!(KeyCode::Up) => { self.focus_up(); },
|
||||
key!(KeyCode::Down) => { self.focus_down(); },
|
||||
key!(KeyCode::Left) => { self.focus_left(); },
|
||||
key!(KeyCode::Right) => { self.focus_right(); },
|
||||
// Global play/pause binding
|
||||
key!(KeyCode::Char(' ')) => match self.transport {
|
||||
Some(ref mut transport) => { transport.write().unwrap().toggle_play()?; },
|
||||
|
|
@ -86,14 +77,6 @@ impl Arranger<Tui> {
|
|||
};
|
||||
}
|
||||
}
|
||||
impl Focusable<Tui> for Arrangement<Tui> {
|
||||
fn is_focused (&self) -> bool {
|
||||
self.focused
|
||||
}
|
||||
fn set_focused (&mut self, focused: bool) {
|
||||
self.focused = focused
|
||||
}
|
||||
}
|
||||
impl Handle<Tui> for Arrangement<Tui> {
|
||||
fn handle (&mut self, from: &TuiInput) -> Perhaps<bool> {
|
||||
match from.event() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue