mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
75 lines
2.2 KiB
Rust
75 lines
2.2 KiB
Rust
use crate::*;
|
|
|
|
/// Sections in the arranger app that may be focused
|
|
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
|
pub enum ArrangerFocus {
|
|
/// The transport (toolbar) is focused
|
|
Transport,
|
|
/// The arrangement (grid) is focused
|
|
Arranger,
|
|
/// The phrase list (pool) is focused
|
|
PhrasePool,
|
|
/// The phrase editor (sequencer) is focused
|
|
PhraseEditor,
|
|
}
|
|
|
|
impl FocusEnter for ArrangerApp<Tui> {
|
|
type Item = AppViewFocus<ArrangerFocus>;
|
|
fn focus_enter (&mut self) {
|
|
use AppViewFocus::*;
|
|
use ArrangerFocus::*;
|
|
let focused = self.focused();
|
|
if !self.entered {
|
|
self.entered = focused == Content(Arranger);
|
|
self.app.editor.entered = focused == Content(PhraseEditor);
|
|
self.app.phrases.entered = focused == Content(PhrasePool);
|
|
}
|
|
}
|
|
fn focus_exit (&mut self) {
|
|
if self.entered {
|
|
self.entered = false;
|
|
self.app.editor.entered = false;
|
|
self.app.phrases.entered = false;
|
|
}
|
|
}
|
|
fn focus_entered (&self) -> Option<Self::Item> {
|
|
if self.entered {
|
|
Some(self.focused())
|
|
} else {
|
|
None
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Focus layout of arranger app
|
|
impl FocusGrid for ArrangerApp<Tui> {
|
|
type Item = AppViewFocus<ArrangerFocus>;
|
|
fn focus_cursor (&self) -> (usize, usize) {
|
|
self.cursor
|
|
}
|
|
fn focus_cursor_mut (&mut self) -> &mut (usize, usize) {
|
|
&mut self.cursor
|
|
}
|
|
fn focus_layout (&self) -> &[&[Self::Item]] {
|
|
use AppViewFocus::*;
|
|
use ArrangerFocus::*;
|
|
&[
|
|
&[Menu, Menu ],
|
|
&[Content(Transport), Content(Transport) ],
|
|
&[Content(Arranger), Content(Arranger) ],
|
|
&[Content(PhrasePool), Content(PhraseEditor)],
|
|
]
|
|
}
|
|
fn focus_update (&mut self) {
|
|
use AppViewFocus::*;
|
|
use ArrangerFocus::*;
|
|
let focused = self.focused();
|
|
if let Some(mut status_bar) = self.status_bar {
|
|
status_bar.update(&(
|
|
self.focused(),
|
|
self.app.selected,
|
|
focused == Content(PhraseEditor) && self.entered
|
|
))
|
|
}
|
|
}
|
|
}
|