eliminate all 15 dead_code warnings across au-o2-gui

This commit is contained in:
jess 2026-03-31 18:10:14 -07:00
parent d72443905d
commit 977b3ea410
9 changed files with 236 additions and 12 deletions

View File

@ -98,6 +98,28 @@ pub enum BottomPanelMode {
Visualizer, Visualizer,
} }
impl BottomPanelMode {
pub const ALL: [BottomPanelMode; 6] = [
BottomPanelMode::Editor,
BottomPanelMode::Mixer,
BottomPanelMode::StepSequencer,
BottomPanelMode::ScoreEditor,
BottomPanelMode::ClipLauncher,
BottomPanelMode::Visualizer,
];
pub fn label(&self) -> &'static str {
match self {
Self::Editor => "Editor",
Self::Mixer => "Mixer",
Self::StepSequencer => "Step Seq",
Self::ScoreEditor => "Score",
Self::ClipLauncher => "Clips",
Self::Visualizer => "Visualizer",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum StatusLevel { pub enum StatusLevel {
Info, Info,
@ -244,6 +266,7 @@ pub struct Editor {
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
#[allow(dead_code)]
pub enum Message { pub enum Message {
PlayPressed, PlayPressed,
StopPressed, StopPressed,

View File

@ -98,7 +98,7 @@ impl Default for App {
} }
pub fn main() -> iced::Result { pub fn main() -> iced::Result {
iced::application("Audio Oxide", App::update, App::view) iced::application(App::title, App::update, App::view)
.subscription(App::subscription) .subscription(App::subscription)
.run() .run()
} }
@ -162,6 +162,19 @@ fn apply_time_signature_to_state(state: &mut AppState, num: u8, den: u8) {
} }
impl App { impl App {
fn title(&self) -> String {
match &self.state {
AppState::Editor(editor) => {
let name = editor.project_name();
let dirty = if editor.is_dirty() { " *" } else { "" };
let engine = if editor.has_engine() { "" } else { " [offline]" };
let track_count = editor.tracks_ref().len();
format!("Audio Oxide - {name}{dirty}{engine} ({track_count} tracks)")
}
_ => "Audio Oxide".to_string(),
}
}
fn update(&mut self, message: Message) -> Task<Message> { fn update(&mut self, message: Message) -> Task<Message> {
match message { match message {
Message::ViewRecentProjects => { Message::ViewRecentProjects => {
@ -482,6 +495,9 @@ impl App {
Action::EditorToggleMetronome => { Action::EditorToggleMetronome => {
self.update(Message::EditorMessage(crate::editor::Message::MetronomeToggled)) self.update(Message::EditorMessage(crate::editor::Message::MetronomeToggled))
} }
Action::EditorToggleToolbar => {
Task::none()
}
Action::ZoomInH => { Action::ZoomInH => {
self.update(Message::EditorMessage(crate::editor::Message::ZoomH(1.25))) self.update(Message::EditorMessage(crate::editor::Message::ZoomH(1.25)))
} }

View File

@ -3,7 +3,7 @@ use crate::engine::TransportState;
use crate::gui::icon_button::{button_group, IconButton}; use crate::gui::icon_button::{button_group, IconButton};
use crate::gui::icons::{Icon, IconSet}; use crate::gui::icons::{Icon, IconSet};
use crate::timing::MusicalTime; use crate::timing::MusicalTime;
use iced::widget::{container, row, text, Space}; use iced::widget::{button, container, row, text, Space};
use iced::{Alignment, Background, Color, Element, Length, Theme}; use iced::{Alignment, Background, Color, Element, Length, Theme};
pub fn view<'a>( pub fn view<'a>(
@ -142,11 +142,35 @@ pub fn view<'a>(
.into(), .into(),
]); ]);
let mut mode_row = row![].spacing(2);
for mode in BottomPanelMode::ALL {
let active = show_bottom_panel && *bottom_panel_mode == mode;
let label = mode.label();
let btn = button(text(label).size(10))
.on_press(Message::SetBottomPanelMode(mode))
.padding([2, 6])
.style(move |_theme: &Theme, _status| {
let bg = if active {
Color::from_rgb8(0x44, 0x66, 0x88)
} else {
Color::from_rgb8(0x38, 0x3A, 0x3C)
};
button::Style {
background: Some(Background::Color(bg)),
text_color: Color::from_rgb8(0xDD, 0xDD, 0xDD),
border: iced::Border { radius: 3.0.into(), ..iced::Border::default() },
..button::Style::default()
}
});
mode_row = mode_row.push(btn);
}
let left = Space::new(Length::Fill, 0); let left = Space::new(Length::Fill, 0);
let right = Space::new(Length::Fill, 0); let right = Space::new(Length::Fill, 0);
let bar = row![ let bar = row![
view_toggles, view_toggles,
mode_row,
left, left,
lcd, lcd,
transport_controls, transport_controls,

View File

@ -1,7 +1,8 @@
use crate::automation::AutomationMode;
use crate::config::ProjectConfig; use crate::config::ProjectConfig;
use crate::editor::Message; use crate::editor::Message;
use crate::modules::registry::BUILTIN_MODULES; use crate::modules::registry::BUILTIN_MODULES;
use crate::track::Track; use crate::track::{MonitorMode, Track};
use iced::widget::{ use iced::widget::{
button, column, container, horizontal_rule, pick_list, row, text, vertical_rule, Column, button, column, container, horizontal_rule, pick_list, row, text, vertical_rule, Column,
}; };
@ -26,7 +27,7 @@ pub fn view<'a>(
_session_player_bars: u32, _session_player_bars: u32,
_spatial_mode: crate::engine::atmos::SpatialRenderMode, _spatial_mode: crate::engine::atmos::SpatialRenderMode,
_mono_lane: crate::engine::atmos::MonoLane, _mono_lane: crate::engine::atmos::MonoLane,
_sections: &InspectorSections, sections: &InspectorSections,
_module_params: &'a crate::editor::ModuleParamState, _module_params: &'a crate::editor::ModuleParamState,
_modules_with_gui: &'a std::collections::HashSet<u32>, _modules_with_gui: &'a std::collections::HashSet<u32>,
_groups: &'a [crate::track::TrackGroup], _groups: &'a [crate::track::TrackGroup],
@ -74,8 +75,9 @@ pub fn view<'a>(
let mut add_col = Column::new().spacing(2); let mut add_col = Column::new().spacing(2);
if let Some(idx) = track_index { if let Some(idx) = track_index {
for desc in BUILTIN_MODULES.iter().filter(|d| !d.system) { for desc in BUILTIN_MODULES.iter().filter(|d| !d.system) {
let label = format!("{} - {}", desc.display_name, desc.description);
add_col = add_col.push( add_col = add_col.push(
button(text(desc.display_name).size(10)) button(text(label).size(10))
.on_press(Message::AddModuleToTrack(idx, desc.type_name.to_string())) .on_press(Message::AddModuleToTrack(idx, desc.type_name.to_string()))
.padding([2, 6]) .padding([2, 6])
.style(|_theme: &Theme, status| { .style(|_theme: &Theme, status| {
@ -148,6 +150,102 @@ pub fn view<'a>(
); );
} }
if sections.signal {
col = col.push(horizontal_rule(1));
col = col.push(
button(text("Signal").size(10).color(Color::from_rgb8(0x99, 0x99, 0x99)))
.on_press(Message::ToggleInspectorSignal)
.padding([2, 0])
.style(|_: &Theme, _| button::Style {
background: Some(Background::Color(Color::TRANSPARENT)),
text_color: Color::from_rgb8(0x99, 0x99, 0x99),
..button::Style::default()
}),
);
col = col.push(text(format!("Vol: {:.0}% Pan: {:+.0}", track.volume * 100.0, track.pan * 100.0)).size(10));
let track_idx = track_index.unwrap_or(0);
let monitor_picker = pick_list(
MonitorMode::ALL.as_slice(),
Some(track.monitor_mode),
move |m| Message::SetMonitorMode(track_idx, m),
).width(80);
col = col.push(
row![text("Monitor").size(10).width(60), monitor_picker]
.spacing(4).align_y(iced::Alignment::Center),
);
}
if sections.sends {
col = col.push(
button(text("Sends").size(10).color(Color::from_rgb8(0x99, 0x99, 0x99)))
.on_press(Message::ToggleInspectorSends)
.padding([2, 0])
.style(|_: &Theme, _| button::Style {
background: Some(Background::Color(Color::TRANSPARENT)),
text_color: Color::from_rgb8(0x99, 0x99, 0x99),
..button::Style::default()
}),
);
col = col.push(text(format!("{} sends", track.sends.len())).size(10));
}
if sections.automation {
col = col.push(
button(text("Automation").size(10).color(Color::from_rgb8(0x99, 0x99, 0x99)))
.on_press(Message::ToggleInspectorAutomation)
.padding([2, 0])
.style(|_: &Theme, _| button::Style {
background: Some(Background::Color(Color::TRANSPARENT)),
text_color: Color::from_rgb8(0x99, 0x99, 0x99),
..button::Style::default()
}),
);
let track_idx = track_index.unwrap_or(0);
let auto_mode_picker = pick_list(
AutomationMode::ALL.as_slice(),
Some(track.automation_mode),
move |m| Message::SetTrackAutomationMode(track_idx, m),
).width(80);
col = col.push(
row![text("Mode").size(10).width(60), auto_mode_picker]
.spacing(4).align_y(iced::Alignment::Center),
);
col = col.push(text(format!("{} lanes", track.automation_lanes.len())).size(10));
for lane in &track.automation_lanes {
let (min, max) = lane.value_range();
col = col.push(text(format!("{} [{:.1}..{:.1}]", lane.target, min, max)).size(9));
}
}
if sections.spatial {
col = col.push(
button(text("Spatial").size(10).color(Color::from_rgb8(0x99, 0x99, 0x99)))
.on_press(Message::ToggleInspectorSpatial)
.padding([2, 0])
.style(|_: &Theme, _| button::Style {
background: Some(Background::Color(Color::TRANSPARENT)),
text_color: Color::from_rgb8(0x99, 0x99, 0x99),
..button::Style::default()
}),
);
col = col.push(text(format!("x:{:.1} y:{:.1} z:{:.1}", track.spatial_x, track.spatial_y, track.spatial_z)).size(10));
}
if sections.analysis {
col = col.push(
button(text("Analysis").size(10).color(Color::from_rgb8(0x99, 0x99, 0x99)))
.on_press(Message::ToggleInspectorAnalysis)
.padding([2, 0])
.style(|_: &Theme, _| button::Style {
background: Some(Background::Color(Color::TRANSPARENT)),
text_color: Color::from_rgb8(0x99, 0x99, 0x99),
..button::Style::default()
}),
);
}
col = col.push(horizontal_rule(1)); col = col.push(horizontal_rule(1));
col = col.push(text("Bus").size(10).color(Color::from_rgb8(0x99, 0x99, 0x99))); col = col.push(text("Bus").size(10).color(Color::from_rgb8(0x99, 0x99, 0x99)));
col = col.push(text(&track.bus_name).size(10)); col = col.push(text(&track.bus_name).size(10));

View File

@ -38,11 +38,18 @@ pub fn view<'a>(
_master_pan: f32, _master_pan: f32,
_meter_levels: &'a std::collections::HashMap<String, (f32, f32)>, _meter_levels: &'a std::collections::HashMap<String, (f32, f32)>,
_master_meter: (f32, f32), _master_meter: (f32, f32),
_discovered_plugins: &'a [crate::modules::plugin_host::PluginInfo], discovered_plugins: &'a [crate::modules::plugin_host::PluginInfo],
_show_network_view: bool, _show_network_view: bool,
) -> Element<'a, Message> { ) -> Element<'a, Message> {
let plugin_count = discovered_plugins.len();
let plugin_hint = if plugin_count > 0 {
let paths: Vec<_> = discovered_plugins.iter().map(|p| p.path.display().to_string()).collect();
format!("Mixer ({} plugins: {})", plugin_count, paths.join(", "))
} else {
"Mixer".to_string()
};
let header = container( let header = container(
text("Mixer").size(14).color(Color::from_rgb8(0xAA, 0xAA, 0xAA)), text(plugin_hint).size(14).color(Color::from_rgb8(0xAA, 0xAA, 0xAA)),
) )
.padding([4, 8]); .padding([4, 8]);

View File

@ -1,6 +1,6 @@
use crate::editor::Message; use crate::editor::Message;
use crate::track::Track; use crate::track::Track;
use iced::widget::{column, container, text}; use iced::widget::{column, container, pick_list, row, text};
use iced::{Background, Color, Element, Length, Theme}; use iced::{Background, Color, Element, Length, Theme};
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
@ -12,24 +12,58 @@ pub enum ScoreNoteDuration {
Sixteenth, Sixteenth,
} }
impl ScoreNoteDuration {
pub const ALL: [ScoreNoteDuration; 5] = [
ScoreNoteDuration::Whole,
ScoreNoteDuration::Half,
ScoreNoteDuration::Quarter,
ScoreNoteDuration::Eighth,
ScoreNoteDuration::Sixteenth,
];
}
impl std::fmt::Display for ScoreNoteDuration {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Whole => write!(f, "1"),
Self::Half => write!(f, "1/2"),
Self::Quarter => write!(f, "1/4"),
Self::Eighth => write!(f, "1/8"),
Self::Sixteenth => write!(f, "1/16"),
}
}
}
pub fn view<'a>( pub fn view<'a>(
selected_track: Option<&'a Track>, selected_track: Option<&'a Track>,
_selected_index: Option<usize>, _selected_index: Option<usize>,
_h_zoom: f32, _h_zoom: f32,
_tempo: f32, _tempo: f32,
_time_sig_num: u8, _time_sig_num: u8,
_note_duration: ScoreNoteDuration, note_duration: ScoreNoteDuration,
) -> Element<'a, Message> { ) -> Element<'a, Message> {
let duration_picker = pick_list(
ScoreNoteDuration::ALL.as_slice(),
Some(note_duration),
|d| Message::SetScoreNoteDuration(d),
).width(70);
let content = if let Some(track) = selected_track { let content = if let Some(track) = selected_track {
column![ column![
row![
text("Score Editor").size(14).color(Color::from_rgb8(0xAA, 0xAA, 0xAA)), text("Score Editor").size(14).color(Color::from_rgb8(0xAA, 0xAA, 0xAA)),
duration_picker,
].spacing(8),
text(format!("{} - Score View", track.name)).size(12), text(format!("{} - Score View", track.name)).size(12),
] ]
.spacing(4) .spacing(4)
.padding(8) .padding(8)
} else { } else {
column![ column![
row![
text("Score Editor").size(14).color(Color::from_rgb8(0xAA, 0xAA, 0xAA)), text("Score Editor").size(14).color(Color::from_rgb8(0xAA, 0xAA, 0xAA)),
duration_picker,
].spacing(8),
text("Select a track").size(12).color(Color::from_rgb8(0x77, 0x77, 0x77)), text("Select a track").size(12).color(Color::from_rgb8(0x77, 0x77, 0x77)),
] ]
.spacing(4) .spacing(4)

View File

@ -31,6 +31,7 @@ fn bar_groupings(num: u8, den: u8) -> (u32, u32) {
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
#[allow(dead_code)]
pub enum Message { pub enum Message {
ZoomChanged(f32, f32), ZoomChanged(f32, f32),
PlayheadMoved(MusicalTime), PlayheadMoved(MusicalTime),
@ -329,6 +330,7 @@ impl<'a> Timeline<'a> {
(total_beats as f64 * samples_per_beat) as u64 (total_beats as f64 * samples_per_beat) as u64
} }
#[allow(dead_code)]
fn sample_to_x(&self, sample: u64) -> f32 { fn sample_to_x(&self, sample: u64) -> f32 {
let beats_per_second = self.config.tempo / 60.0; let beats_per_second = self.config.tempo / 60.0;
let total_beats = sample as f32 / self.config.sample_rate as f32 * beats_per_second; let total_beats = sample as f32 / self.config.sample_rate as f32 * beats_per_second;

View File

@ -58,7 +58,26 @@ pub fn view<'a>(track: &'a Track, icons: &'a IconSet, height: f32) -> Element<'a
.hint("Record Arm") .hint("Record Arm")
.into(); .into();
let controls = row![mute_btn, solo_btn, rec_btn].spacing(2); let freeze_btn: Element<'a, Message> = button(
text(if track.frozen { "F*" } else { "F" }).size(10)
)
.on_press(Message::FreezeToggled)
.padding([2, 5])
.style(move |_theme: &Theme, _status| {
let bg = if track.frozen {
Color::from_rgb8(0x33, 0x77, 0xBB)
} else {
Color::TRANSPARENT
};
button::Style {
background: Some(Background::Color(bg)),
text_color: Color::from_rgb8(0x99, 0x99, 0x99),
..button::Style::default()
}
})
.into();
let controls = row![mute_btn, solo_btn, rec_btn, freeze_btn].spacing(2);
let volume_slider = slider(0.0..=1.0, track.volume, Message::VolumeChanged) let volume_slider = slider(0.0..=1.0, track.volume, Message::VolumeChanged)
.step(0.01) .step(0.01)

View File

@ -42,6 +42,7 @@ pub fn map_key_press_to_action(
"x" => Some(Action::EditorToggleMixer), "x" => Some(Action::EditorToggleMixer),
"c" => Some(Action::EditorToggleCycle), "c" => Some(Action::EditorToggleCycle),
"k" => Some(Action::EditorToggleMetronome), "k" => Some(Action::EditorToggleMetronome),
"t" => Some(Action::EditorToggleToolbar),
"q" => Some(Action::Quantize), "q" => Some(Action::Quantize),
"," => Some(Action::EditorRewind), "," => Some(Action::EditorRewind),
_ => None, _ => None,