mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
wip: focus refactor, e10
This commit is contained in:
parent
6127aa4b30
commit
6a25a3b858
3 changed files with 60 additions and 27 deletions
|
|
@ -7,8 +7,10 @@ pub struct PhrasesView<'a, T: PhrasesViewState>(pub &'a T);
|
|||
pub struct PhraseView<'a, T: PhraseViewState>(pub &'a T);
|
||||
|
||||
pub trait TransportViewState: ClockApi + Send + Sync {
|
||||
fn transport_selected (&self) -> TransportFocus;
|
||||
fn transport_focused (&self) -> bool;
|
||||
fn transport_selected (&self) -> Option<TransportFocus>;
|
||||
fn transport_focused (&self) -> bool {
|
||||
self.transport_selected().is_some()
|
||||
}
|
||||
fn transport_bpm_value (&self) -> f64 {
|
||||
self.bpm().get()
|
||||
}
|
||||
|
|
@ -22,21 +24,33 @@ pub trait TransportViewState: ClockApi + Send + Sync {
|
|||
self.current().usec.format_msu()
|
||||
}
|
||||
}
|
||||
macro_rules! impl_transport_view_state {
|
||||
($Struct:ident :: $field:ident) => {
|
||||
impl TransportViewState for $Struct {
|
||||
fn transport_selected (&self) -> TransportFocus {
|
||||
self.focused().inner()
|
||||
}
|
||||
fn transport_focused (&self) -> bool {
|
||||
true
|
||||
}
|
||||
impl TransportViewState for TransportTui {
|
||||
fn transport_selected (&self) -> Option<TransportFocus> {
|
||||
if let AppFocus::Content(focus) = self.focus.inner() {
|
||||
Some(focus)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
impl TransportViewState for SequencerTui {
|
||||
fn transport_selected (&self) -> Option<TransportFocus> {
|
||||
if let AppFocus::Content(SequencerFocus::Transport(focus)) = self.focus.inner() {
|
||||
Some(focus)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
impl TransportViewState for ArrangerTui {
|
||||
fn transport_selected (&self) -> Option<TransportFocus> {
|
||||
if let AppFocus::Content(ArrangerFocus::Transport(focus)) = self.focus.inner() {
|
||||
Some(focus)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
impl_transport_view_state!(TransportTui::clock);
|
||||
impl_transport_view_state!(SequencerTui::clock);
|
||||
impl_transport_view_state!(ArrangerTui::clock);
|
||||
|
||||
pub trait ArrangerViewState {
|
||||
fn arranger_focused (&self) -> bool;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue