highlight phrase selectors

This commit is contained in:
🪞👃🪞 2024-11-26 13:51:16 +01:00
parent bbd784f58b
commit c0c32c89b7
3 changed files with 27 additions and 11 deletions

View file

@ -60,8 +60,8 @@ impl_focus!(TransportTui TransportFocus [
&[
PlayPause,
Bpm,
Quant,
Sync,
Quant,
Clock,
],
]);

View file

@ -8,20 +8,28 @@ pub struct PhraseSelector<'a> {
}
impl<'a> PhraseSelector<'a> {
pub fn play_phrase <T: HasPhrase> (state: &'a T) -> Self {
pub fn play_phrase <T: HasPhrase> (
state: &'a T,
focused: bool,
entered: bool,
) -> Self {
Self {
focused,
entered: focused && entered,
phrase: state.next_phrase(),
title: "Now:",
phrase: state.play_phrase(),
focused: false,
entered: false,
}
}
pub fn next_phrase <T: HasPhrase> (state: &'a T) -> Self {
pub fn next_phrase <T: HasPhrase> (
state: &'a T,
focused: bool,
entered: bool,
) -> Self {
Self {
title: "Next:",
focused,
entered: focused && entered,
phrase: state.next_phrase(),
focused: false,
entered: false,
title: "Next:",
}
}
}

View file

@ -7,8 +7,16 @@ impl Content for SequencerTui {
TransportView::from(self),
Split::right(20,
col_up!(
PhraseSelector::play_phrase(&self.player).fixed_y(4),
PhraseSelector::next_phrase(&self.player).fixed_y(4),
PhraseSelector::play_phrase(
&self.player,
self.focused() == SequencerFocus::PhrasePlay,
self.entered()
).fixed_y(4),
PhraseSelector::next_phrase(
&self.player,
self.focused() == SequencerFocus::PhraseNext,
self.entered()
).fixed_y(4),
PhraseListView::from(self),
),
PhraseView::from(self),