Feat: continue refactoring

This commit is contained in:
2026-02-01 13:39:25 +01:00
parent c356aebfde
commit dd77f6d92d
20 changed files with 766 additions and 581 deletions

View File

@@ -1,3 +1,5 @@
use super::CyclicEnum;
#[derive(Clone, Copy, PartialEq, Eq, Default)]
pub enum OptionsFocus {
#[default]
@@ -21,6 +23,29 @@ pub enum OptionsFocus {
MidiInput3,
}
impl CyclicEnum for OptionsFocus {
const VARIANTS: &'static [Self] = &[
Self::ColorScheme,
Self::RefreshRate,
Self::RuntimeHighlight,
Self::ShowScope,
Self::ShowSpectrum,
Self::ShowCompletion,
Self::FlashBrightness,
Self::LinkEnabled,
Self::StartStopSync,
Self::Quantum,
Self::MidiOutput0,
Self::MidiOutput1,
Self::MidiOutput2,
Self::MidiOutput3,
Self::MidiInput0,
Self::MidiInput1,
Self::MidiInput2,
Self::MidiInput3,
];
}
#[derive(Default)]
pub struct OptionsState {
pub focus: OptionsFocus,
@@ -28,48 +53,10 @@ pub struct OptionsState {
impl OptionsState {
pub fn next_focus(&mut self) {
self.focus = match self.focus {
OptionsFocus::ColorScheme => OptionsFocus::RefreshRate,
OptionsFocus::RefreshRate => OptionsFocus::RuntimeHighlight,
OptionsFocus::RuntimeHighlight => OptionsFocus::ShowScope,
OptionsFocus::ShowScope => OptionsFocus::ShowSpectrum,
OptionsFocus::ShowSpectrum => OptionsFocus::ShowCompletion,
OptionsFocus::ShowCompletion => OptionsFocus::FlashBrightness,
OptionsFocus::FlashBrightness => OptionsFocus::LinkEnabled,
OptionsFocus::LinkEnabled => OptionsFocus::StartStopSync,
OptionsFocus::StartStopSync => OptionsFocus::Quantum,
OptionsFocus::Quantum => OptionsFocus::MidiOutput0,
OptionsFocus::MidiOutput0 => OptionsFocus::MidiOutput1,
OptionsFocus::MidiOutput1 => OptionsFocus::MidiOutput2,
OptionsFocus::MidiOutput2 => OptionsFocus::MidiOutput3,
OptionsFocus::MidiOutput3 => OptionsFocus::MidiInput0,
OptionsFocus::MidiInput0 => OptionsFocus::MidiInput1,
OptionsFocus::MidiInput1 => OptionsFocus::MidiInput2,
OptionsFocus::MidiInput2 => OptionsFocus::MidiInput3,
OptionsFocus::MidiInput3 => OptionsFocus::ColorScheme,
};
self.focus = self.focus.next();
}
pub fn prev_focus(&mut self) {
self.focus = match self.focus {
OptionsFocus::ColorScheme => OptionsFocus::MidiInput3,
OptionsFocus::RefreshRate => OptionsFocus::ColorScheme,
OptionsFocus::RuntimeHighlight => OptionsFocus::RefreshRate,
OptionsFocus::ShowScope => OptionsFocus::RuntimeHighlight,
OptionsFocus::ShowSpectrum => OptionsFocus::ShowScope,
OptionsFocus::ShowCompletion => OptionsFocus::ShowSpectrum,
OptionsFocus::FlashBrightness => OptionsFocus::ShowCompletion,
OptionsFocus::LinkEnabled => OptionsFocus::FlashBrightness,
OptionsFocus::StartStopSync => OptionsFocus::LinkEnabled,
OptionsFocus::Quantum => OptionsFocus::StartStopSync,
OptionsFocus::MidiOutput0 => OptionsFocus::Quantum,
OptionsFocus::MidiOutput1 => OptionsFocus::MidiOutput0,
OptionsFocus::MidiOutput2 => OptionsFocus::MidiOutput1,
OptionsFocus::MidiOutput3 => OptionsFocus::MidiOutput2,
OptionsFocus::MidiInput0 => OptionsFocus::MidiOutput3,
OptionsFocus::MidiInput1 => OptionsFocus::MidiInput0,
OptionsFocus::MidiInput2 => OptionsFocus::MidiInput1,
OptionsFocus::MidiInput3 => OptionsFocus::MidiInput2,
};
self.focus = self.focus.prev();
}
}