Feat: early mouse support
This commit is contained in:
@@ -44,4 +44,4 @@ pub use mute::MuteState;
|
||||
pub use playback::{PlaybackState, StagedChange, StagedMuteChange, StagedPropChange};
|
||||
pub use project::ProjectState;
|
||||
pub use sample_browser::{SampleBrowserState, SampleTree};
|
||||
pub use ui::{DictFocus, FlashKind, HelpFocus, UiState};
|
||||
pub use ui::{DictFocus, FlashKind, HelpFocus, MinimapMode, UiState};
|
||||
|
||||
@@ -46,6 +46,44 @@ impl CyclicEnum for OptionsFocus {
|
||||
];
|
||||
}
|
||||
|
||||
const FOCUS_LINES: &[(OptionsFocus, usize)] = &[
|
||||
(OptionsFocus::ColorScheme, 2),
|
||||
(OptionsFocus::HueRotation, 3),
|
||||
(OptionsFocus::RefreshRate, 4),
|
||||
(OptionsFocus::RuntimeHighlight, 5),
|
||||
(OptionsFocus::ShowScope, 6),
|
||||
(OptionsFocus::ShowSpectrum, 7),
|
||||
(OptionsFocus::ShowCompletion, 8),
|
||||
(OptionsFocus::LinkEnabled, 12),
|
||||
(OptionsFocus::StartStopSync, 13),
|
||||
(OptionsFocus::Quantum, 14),
|
||||
(OptionsFocus::MidiOutput0, 24),
|
||||
(OptionsFocus::MidiOutput1, 25),
|
||||
(OptionsFocus::MidiOutput2, 26),
|
||||
(OptionsFocus::MidiOutput3, 27),
|
||||
(OptionsFocus::MidiInput0, 31),
|
||||
(OptionsFocus::MidiInput1, 32),
|
||||
(OptionsFocus::MidiInput2, 33),
|
||||
(OptionsFocus::MidiInput3, 34),
|
||||
];
|
||||
|
||||
impl OptionsFocus {
|
||||
pub fn line_index(self) -> usize {
|
||||
FOCUS_LINES
|
||||
.iter()
|
||||
.find(|(f, _)| *f == self)
|
||||
.map(|(_, l)| *l)
|
||||
.unwrap_or(0)
|
||||
}
|
||||
|
||||
pub fn at_line(line: usize) -> Option<OptionsFocus> {
|
||||
FOCUS_LINES
|
||||
.iter()
|
||||
.find(|(_, l)| *l == line)
|
||||
.map(|(f, _)| *f)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct OptionsState {
|
||||
pub focus: OptionsFocus,
|
||||
|
||||
@@ -8,6 +8,14 @@ use crate::page::Page;
|
||||
use crate::state::effects::FxId;
|
||||
use crate::state::{ColorScheme, Modal};
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Default)]
|
||||
pub enum MinimapMode {
|
||||
#[default]
|
||||
Hidden,
|
||||
Timed(Instant),
|
||||
Sticky,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
|
||||
pub enum FlashKind {
|
||||
#[default]
|
||||
@@ -49,7 +57,7 @@ pub struct UiState {
|
||||
pub show_title: bool,
|
||||
pub runtime_highlight: bool,
|
||||
pub show_completion: bool,
|
||||
pub minimap_until: Option<Instant>,
|
||||
pub minimap: MinimapMode,
|
||||
pub color_scheme: ColorScheme,
|
||||
pub hue_rotation: f32,
|
||||
pub effects: RefCell<EffectManager<FxId>>,
|
||||
@@ -81,7 +89,7 @@ impl Default for UiState {
|
||||
show_title: true,
|
||||
runtime_highlight: false,
|
||||
show_completion: true,
|
||||
minimap_until: None,
|
||||
minimap: MinimapMode::Hidden,
|
||||
color_scheme: ColorScheme::default(),
|
||||
hue_rotation: 0.0,
|
||||
effects: RefCell::new(EffectManager::default()),
|
||||
@@ -138,4 +146,16 @@ impl UiState {
|
||||
.map(|t| Instant::now() < t)
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
pub fn show_minimap(&self) -> bool {
|
||||
match self.minimap {
|
||||
MinimapMode::Hidden => false,
|
||||
MinimapMode::Timed(until) => Instant::now() < until,
|
||||
MinimapMode::Sticky => true,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn dismiss_minimap(&mut self) {
|
||||
self.minimap = MinimapMode::Hidden;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user