mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
wip: refactor pt.6, fixed tek_api
This commit is contained in:
parent
5df08409e5
commit
869d92110d
29 changed files with 1678 additions and 1679 deletions
68
crates/tek_tui/src/tui_arranger_foc.rs
Normal file
68
crates/tek_tui/src/tui_arranger_foc.rs
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
use crate::*;
|
||||
|
||||
/// Sections in the arranger app that may be focused
|
||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||
pub enum ArrangerAppFocus {
|
||||
/// The transport (toolbar) is focused
|
||||
Transport,
|
||||
/// The arrangement (grid) is focused
|
||||
Arrangement,
|
||||
/// The phrase list (pool) is focused
|
||||
PhrasePool,
|
||||
/// The phrase editor (sequencer) is focused
|
||||
PhraseEditor,
|
||||
}
|
||||
|
||||
/// Focus layout of arranger app
|
||||
impl<E: Engine> FocusGrid for ArrangerApp<E> {
|
||||
type Item = ArrangerAppFocus;
|
||||
fn cursor (&self) -> (usize, usize) { self.focus_cursor }
|
||||
fn cursor_mut (&mut self) -> &mut (usize, usize) { &mut self.focus_cursor }
|
||||
fn focus_enter (&mut self) {
|
||||
let focused = self.focused();
|
||||
if !self.entered {
|
||||
self.entered = true;
|
||||
use ArrangerAppFocus::*;
|
||||
if let Some(transport) = self.transport.as_ref() {
|
||||
//transport.write().unwrap().entered = focused == Transport
|
||||
}
|
||||
self.arrangement.entered = focused == Arrangement;
|
||||
self.phrases.write().unwrap().entered = focused == PhrasePool;
|
||||
self.editor.entered = focused == PhraseEditor;
|
||||
}
|
||||
}
|
||||
fn focus_exit (&mut self) {
|
||||
if self.entered {
|
||||
self.entered = false;
|
||||
self.arrangement.entered = false;
|
||||
self.editor.entered = false;
|
||||
self.phrases.write().unwrap().entered = false;
|
||||
}
|
||||
}
|
||||
fn entered (&self) -> Option<ArrangerAppFocus> {
|
||||
if self.entered {
|
||||
Some(self.focused())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
fn layout (&self) -> &[&[ArrangerAppFocus]] {
|
||||
use ArrangerAppFocus::*;
|
||||
&[
|
||||
&[Transport, Transport],
|
||||
&[Arrangement, Arrangement],
|
||||
&[PhrasePool, PhraseEditor],
|
||||
]
|
||||
}
|
||||
fn update_focus (&mut self) {
|
||||
use ArrangerAppFocus::*;
|
||||
let focused = self.focused();
|
||||
if let Some(transport) = self.transport.as_ref() {
|
||||
transport.write().unwrap().focused = focused == Transport
|
||||
}
|
||||
self.arrangement.focused = focused == Arrangement;
|
||||
self.phrases.write().unwrap().focused = focused == PhrasePool;
|
||||
self.editor.focused = focused == PhraseEditor;
|
||||
self.update_status();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue