This commit is contained in:
@@ -202,11 +202,33 @@ pub enum EngineSection {
|
||||
#[default]
|
||||
Devices,
|
||||
Settings,
|
||||
Link,
|
||||
MidiOutput,
|
||||
MidiInput,
|
||||
Samples,
|
||||
}
|
||||
|
||||
impl CyclicEnum for EngineSection {
|
||||
const VARIANTS: &'static [Self] = &[Self::Devices, Self::Settings, Self::Samples];
|
||||
const VARIANTS: &'static [Self] = &[
|
||||
Self::Devices,
|
||||
Self::Settings,
|
||||
Self::Link,
|
||||
Self::MidiOutput,
|
||||
Self::MidiInput,
|
||||
Self::Samples,
|
||||
];
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Default)]
|
||||
pub enum LinkSetting {
|
||||
#[default]
|
||||
Enabled,
|
||||
StartStopSync,
|
||||
Quantum,
|
||||
}
|
||||
|
||||
impl CyclicEnum for LinkSetting {
|
||||
const VARIANTS: &'static [Self] = &[Self::Enabled, Self::StartStopSync, Self::Quantum];
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Default)]
|
||||
@@ -271,6 +293,9 @@ pub struct AudioSettings {
|
||||
pub section: EngineSection,
|
||||
pub device_kind: DeviceKind,
|
||||
pub setting_kind: SettingKind,
|
||||
pub link_setting: LinkSetting,
|
||||
pub midi_output_slot: usize,
|
||||
pub midi_input_slot: usize,
|
||||
pub output_devices: Vec<AudioDeviceInfo>,
|
||||
pub input_devices: Vec<AudioDeviceInfo>,
|
||||
pub output_list: ListSelectState,
|
||||
@@ -288,6 +313,9 @@ impl Default for AudioSettings {
|
||||
section: EngineSection::default(),
|
||||
device_kind: DeviceKind::default(),
|
||||
setting_kind: SettingKind::default(),
|
||||
link_setting: LinkSetting::default(),
|
||||
midi_output_slot: 0,
|
||||
midi_input_slot: 0,
|
||||
output_devices: doux::audio::list_output_devices(),
|
||||
input_devices: doux::audio::list_input_devices(),
|
||||
output_list: ListSelectState {
|
||||
@@ -313,9 +341,12 @@ impl AudioSettings {
|
||||
pub fn new_plugin() -> Self {
|
||||
Self {
|
||||
config: AudioConfig::default(),
|
||||
section: EngineSection::default(),
|
||||
section: EngineSection::Settings,
|
||||
device_kind: DeviceKind::default(),
|
||||
setting_kind: SettingKind::default(),
|
||||
setting_kind: SettingKind::Polyphony,
|
||||
link_setting: LinkSetting::default(),
|
||||
midi_output_slot: 0,
|
||||
midi_input_slot: 0,
|
||||
output_devices: Vec::new(),
|
||||
input_devices: Vec::new(),
|
||||
output_list: ListSelectState {
|
||||
@@ -346,7 +377,7 @@ impl AudioSettings {
|
||||
match self.section {
|
||||
EngineSection::Settings => EngineSection::Samples,
|
||||
EngineSection::Samples => EngineSection::Settings,
|
||||
EngineSection::Devices => EngineSection::Settings,
|
||||
_ => EngineSection::Settings,
|
||||
}
|
||||
} else {
|
||||
self.section.next()
|
||||
@@ -358,7 +389,7 @@ impl AudioSettings {
|
||||
match self.section {
|
||||
EngineSection::Settings => EngineSection::Samples,
|
||||
EngineSection::Samples => EngineSection::Settings,
|
||||
EngineSection::Devices => EngineSection::Settings,
|
||||
_ => EngineSection::Settings,
|
||||
}
|
||||
} else {
|
||||
self.section.prev()
|
||||
@@ -389,6 +420,30 @@ impl AudioSettings {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn next_link_setting(&mut self) {
|
||||
self.link_setting = self.link_setting.next();
|
||||
}
|
||||
|
||||
pub fn prev_link_setting(&mut self) {
|
||||
self.link_setting = self.link_setting.prev();
|
||||
}
|
||||
|
||||
pub fn next_midi_output_slot(&mut self) {
|
||||
self.midi_output_slot = (self.midi_output_slot + 1).min(3);
|
||||
}
|
||||
|
||||
pub fn prev_midi_output_slot(&mut self) {
|
||||
self.midi_output_slot = self.midi_output_slot.saturating_sub(1);
|
||||
}
|
||||
|
||||
pub fn next_midi_input_slot(&mut self) {
|
||||
self.midi_input_slot = (self.midi_input_slot + 1).min(3);
|
||||
}
|
||||
|
||||
pub fn prev_midi_input_slot(&mut self) {
|
||||
self.midi_input_slot = self.midi_input_slot.saturating_sub(1);
|
||||
}
|
||||
|
||||
pub fn current_output_device_index(&self) -> usize {
|
||||
match &self.config.output_device {
|
||||
Some(name) => self
|
||||
|
||||
@@ -30,7 +30,7 @@ pub mod sample_browser;
|
||||
pub mod undo;
|
||||
pub mod ui;
|
||||
|
||||
pub use audio::{AudioSettings, DeviceKind, EngineSection, MainLayout, Metrics, ScopeMode, SettingKind, SpectrumMode};
|
||||
pub use audio::{AudioSettings, DeviceKind, EngineSection, LinkSetting, MainLayout, Metrics, ScopeMode, SettingKind, SpectrumMode};
|
||||
pub use color_scheme::ColorScheme;
|
||||
pub use editor::{
|
||||
CopiedStepData, CopiedSteps, EditorContext, EditorTarget, EuclideanField, PatternField,
|
||||
|
||||
@@ -18,17 +18,6 @@ pub enum OptionsFocus {
|
||||
Font,
|
||||
ZoomFactor,
|
||||
WindowSize,
|
||||
LinkEnabled,
|
||||
StartStopSync,
|
||||
Quantum,
|
||||
MidiOutput0,
|
||||
MidiOutput1,
|
||||
MidiOutput2,
|
||||
MidiOutput3,
|
||||
MidiInput0,
|
||||
MidiInput1,
|
||||
MidiInput2,
|
||||
MidiInput3,
|
||||
ResetOnboarding,
|
||||
LoadDemoOnStartup,
|
||||
}
|
||||
@@ -50,17 +39,6 @@ impl CyclicEnum for OptionsFocus {
|
||||
Self::Font,
|
||||
Self::ZoomFactor,
|
||||
Self::WindowSize,
|
||||
Self::LinkEnabled,
|
||||
Self::StartStopSync,
|
||||
Self::Quantum,
|
||||
Self::MidiOutput0,
|
||||
Self::MidiOutput1,
|
||||
Self::MidiOutput2,
|
||||
Self::MidiOutput3,
|
||||
Self::MidiInput0,
|
||||
Self::MidiInput1,
|
||||
Self::MidiInput2,
|
||||
Self::MidiInput3,
|
||||
Self::ResetOnboarding,
|
||||
Self::LoadDemoOnStartup,
|
||||
];
|
||||
@@ -72,25 +50,7 @@ const PLUGIN_ONLY: &[OptionsFocus] = &[
|
||||
OptionsFocus::WindowSize,
|
||||
];
|
||||
|
||||
const STANDALONE_ONLY: &[OptionsFocus] = &[
|
||||
OptionsFocus::LinkEnabled,
|
||||
OptionsFocus::StartStopSync,
|
||||
OptionsFocus::Quantum,
|
||||
OptionsFocus::MidiOutput0,
|
||||
OptionsFocus::MidiOutput1,
|
||||
OptionsFocus::MidiOutput2,
|
||||
OptionsFocus::MidiOutput3,
|
||||
OptionsFocus::MidiInput0,
|
||||
OptionsFocus::MidiInput1,
|
||||
OptionsFocus::MidiInput2,
|
||||
OptionsFocus::MidiInput3,
|
||||
OptionsFocus::ResetOnboarding,
|
||||
OptionsFocus::LoadDemoOnStartup,
|
||||
];
|
||||
|
||||
/// Section layout: header line, divider line, then option lines.
|
||||
/// Each entry gives the raw line offsets assuming ALL sections are visible
|
||||
/// (plugin mode with Font/Zoom/Window shown).
|
||||
const FULL_LAYOUT: &[(OptionsFocus, usize)] = &[
|
||||
// DISPLAY section: header=0, divider=1
|
||||
(OptionsFocus::ColorScheme, 2),
|
||||
@@ -108,24 +68,9 @@ const FULL_LAYOUT: &[(OptionsFocus, usize)] = &[
|
||||
(OptionsFocus::Font, 14),
|
||||
(OptionsFocus::ZoomFactor, 15),
|
||||
(OptionsFocus::WindowSize, 16),
|
||||
// blank=17, ABLETON LINK header=18, divider=19
|
||||
(OptionsFocus::LinkEnabled, 20),
|
||||
(OptionsFocus::StartStopSync, 21),
|
||||
(OptionsFocus::Quantum, 22),
|
||||
// blank=23, SESSION header=24, divider=25, Tempo=26, Beat=27, Phase=28
|
||||
// blank=29, MIDI OUTPUTS header=30, divider=31
|
||||
(OptionsFocus::MidiOutput0, 32),
|
||||
(OptionsFocus::MidiOutput1, 33),
|
||||
(OptionsFocus::MidiOutput2, 34),
|
||||
(OptionsFocus::MidiOutput3, 35),
|
||||
// blank=36, MIDI INPUTS header=37, divider=38
|
||||
(OptionsFocus::MidiInput0, 39),
|
||||
(OptionsFocus::MidiInput1, 40),
|
||||
(OptionsFocus::MidiInput2, 41),
|
||||
(OptionsFocus::MidiInput3, 42),
|
||||
// blank=43, ONBOARDING header=44, divider=45
|
||||
(OptionsFocus::ResetOnboarding, 46),
|
||||
(OptionsFocus::LoadDemoOnStartup, 47),
|
||||
// blank=17, ONBOARDING header=18, divider=19
|
||||
(OptionsFocus::ResetOnboarding, 20),
|
||||
(OptionsFocus::LoadDemoOnStartup, 21),
|
||||
];
|
||||
|
||||
impl OptionsFocus {
|
||||
@@ -133,17 +78,10 @@ impl OptionsFocus {
|
||||
PLUGIN_ONLY.contains(&self)
|
||||
}
|
||||
|
||||
fn is_standalone_only(self) -> bool {
|
||||
STANDALONE_ONLY.contains(&self)
|
||||
}
|
||||
|
||||
fn is_visible(self, plugin_mode: bool) -> bool {
|
||||
if self.is_plugin_only() && !plugin_mode {
|
||||
return false;
|
||||
}
|
||||
if self.is_standalone_only() && plugin_mode {
|
||||
return false;
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
@@ -171,26 +109,12 @@ pub fn total_lines(plugin_mode: bool) -> usize {
|
||||
.unwrap_or(0)
|
||||
}
|
||||
|
||||
/// Compute (focus, line_index) pairs for only the visible options,
|
||||
/// with line indices adjusted to account for hidden sections.
|
||||
fn visible_layout(plugin_mode: bool) -> Vec<(OptionsFocus, usize)> {
|
||||
// Start from the full layout and compute adjusted line numbers.
|
||||
// Hidden items + their section headers/dividers/blanks shrink the layout.
|
||||
|
||||
// We know the exact section structure, so we compute the offset to subtract
|
||||
// based on which sections are hidden.
|
||||
let mut offset: usize = 0;
|
||||
|
||||
// Font/Zoom/Window lines (14,15,16) hidden when !plugin_mode
|
||||
if !plugin_mode {
|
||||
offset += 3; // 3 lines for Font, ZoomFactor, WindowSize
|
||||
}
|
||||
|
||||
// Link + Session + MIDI sections hidden when plugin_mode
|
||||
// These span from blank(17) through MidiInput3(42) = 26 lines
|
||||
if plugin_mode {
|
||||
let link_section_lines = 26;
|
||||
offset += link_section_lines;
|
||||
offset += 3;
|
||||
}
|
||||
|
||||
let mut result = Vec::new();
|
||||
@@ -198,11 +122,9 @@ fn visible_layout(plugin_mode: bool) -> Vec<(OptionsFocus, usize)> {
|
||||
if !focus.is_visible(plugin_mode) {
|
||||
continue;
|
||||
}
|
||||
// Lines at or below index 13 (PerformanceMode) are never shifted
|
||||
let adjusted = if raw_line <= 13 {
|
||||
raw_line
|
||||
} else if !plugin_mode && raw_line <= 16 {
|
||||
// Font/Zoom/Window — these are hidden, skip
|
||||
continue;
|
||||
} else {
|
||||
raw_line - offset
|
||||
|
||||
Reference in New Issue
Block a user