mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
wip: p.43, e=22, almost 10kloc!
This commit is contained in:
parent
dbf6e353b7
commit
a7998860b1
9 changed files with 1177 additions and 1166 deletions
74
crates/tek_tui/src/tui_arranger_focus.rs
Normal file
74
crates/tek_tui/src/tui_arranger_focus.rs
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
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> {
|
||||
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
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue