cmdsys: focus enter

This commit is contained in:
🪞👃🪞 2024-11-09 02:22:23 +01:00
parent c551f83d5c
commit 31c1db8a5c
3 changed files with 28 additions and 9 deletions

View file

@ -10,8 +10,6 @@ pub type PhraseChunk = [Vec<PhraseMessage>];
pub struct Sequencer<E: Engine> {
/// JACK client handle (needs to not be dropped for standalone mode to work).
pub jack: Arc<RwLock<JackClient>>,
/// Which view is focused
pub focus_cursor: (usize, usize),
/// Controls the JACK transport.
pub transport: Option<Arc<RwLock<TransportToolbar<E>>>>,
/// Global timebase
@ -22,6 +20,10 @@ pub struct Sequencer<E: Engine> {
pub editor: PhraseEditor<E>,
/// Phrase player
pub player: PhrasePlayer,
/// Which view is focused
pub focus_cursor: (usize, usize),
/// Whether the currently focused item is entered
pub entered: bool,
}
/// Sections in the sequencer app that may be focused
#[derive(Copy, Clone, PartialEq, Eq)] pub enum SequencerFocus {
@ -172,8 +174,13 @@ impl<E: Engine> FocusGrid for Sequencer<E> {
&[SequencerFocus::Transport],
&[SequencerFocus::PhrasePool, SequencerFocus::PhraseEditor],
] }
fn focus_enter (&mut self) { self.entered = true }
fn focus_exit (&mut self) { self.entered = false }
fn entered (&self) -> Option<Self::Item> {
if self.entered { Some(self.focused()) } else { None }
}
fn update_focus (&mut self) {
let focused = *self.focused();
let focused = self.focused();
if let Some(transport) = self.transport.as_ref() {
transport.write().unwrap().focused = focused == SequencerFocus::Transport
}