A ton of bug fixes
This commit is contained in:
@@ -45,7 +45,7 @@ fn render_settings_section(frame: &mut Frame, app: &App, area: Rect) {
|
||||
let [devices_area, _, settings_area, _, samples_area] = Layout::vertical([
|
||||
Constraint::Length(devices_height),
|
||||
Constraint::Length(1),
|
||||
Constraint::Length(7),
|
||||
Constraint::Length(8),
|
||||
Constraint::Length(1),
|
||||
Constraint::Min(6),
|
||||
])
|
||||
@@ -106,7 +106,11 @@ fn truncate_name(name: &str, max_len: usize) -> String {
|
||||
|
||||
fn list_height(item_count: usize) -> u16 {
|
||||
let visible = item_count.min(5) as u16;
|
||||
if item_count > 5 { visible + 1 } else { visible }
|
||||
if item_count > 5 {
|
||||
visible + 1
|
||||
} else {
|
||||
visible
|
||||
}
|
||||
}
|
||||
|
||||
fn devices_section_height(app: &App) -> u16 {
|
||||
@@ -116,10 +120,8 @@ fn devices_section_height(app: &App) -> u16 {
|
||||
}
|
||||
|
||||
fn render_section_header(frame: &mut Frame, title: &str, focused: bool, area: Rect) {
|
||||
let [header_area, divider_area] = Layout::vertical([
|
||||
Constraint::Length(1),
|
||||
Constraint::Length(1),
|
||||
]).areas(area);
|
||||
let [header_area, divider_area] =
|
||||
Layout::vertical([Constraint::Length(1), Constraint::Length(1)]).areas(area);
|
||||
|
||||
let header_style = if focused {
|
||||
Style::new().fg(Color::Yellow).add_modifier(Modifier::BOLD)
|
||||
@@ -139,10 +141,8 @@ fn render_section_header(frame: &mut Frame, title: &str, focused: bool, area: Re
|
||||
fn render_devices(frame: &mut Frame, app: &App, area: Rect) {
|
||||
let section_focused = app.audio.section == EngineSection::Devices;
|
||||
|
||||
let [header_area, content_area] = Layout::vertical([
|
||||
Constraint::Length(2),
|
||||
Constraint::Min(1),
|
||||
]).areas(area);
|
||||
let [header_area, content_area] =
|
||||
Layout::vertical([Constraint::Length(2), Constraint::Min(1)]).areas(area);
|
||||
|
||||
render_section_header(frame, "DEVICES", section_focused, header_area);
|
||||
|
||||
@@ -150,14 +150,17 @@ fn render_devices(frame: &mut Frame, app: &App, area: Rect) {
|
||||
Constraint::Percentage(48),
|
||||
Constraint::Length(3),
|
||||
Constraint::Percentage(48),
|
||||
]).areas(content_area);
|
||||
])
|
||||
.areas(content_area);
|
||||
|
||||
let output_focused = section_focused && app.audio.device_kind == DeviceKind::Output;
|
||||
let input_focused = section_focused && app.audio.device_kind == DeviceKind::Input;
|
||||
|
||||
render_device_column(
|
||||
frame, output_col,
|
||||
"Output", &app.audio.output_devices,
|
||||
frame,
|
||||
output_col,
|
||||
"Output",
|
||||
&app.audio.output_devices,
|
||||
app.audio.current_output_device_index(),
|
||||
app.audio.output_list.cursor,
|
||||
app.audio.output_list.scroll_offset,
|
||||
@@ -172,8 +175,10 @@ fn render_devices(frame: &mut Frame, app: &App, area: Rect) {
|
||||
frame.render_widget(Paragraph::new(sep_lines), separator);
|
||||
|
||||
render_device_column(
|
||||
frame, input_col,
|
||||
"Input", &app.audio.input_devices,
|
||||
frame,
|
||||
input_col,
|
||||
"Input",
|
||||
&app.audio.input_devices,
|
||||
app.audio.current_input_device_index(),
|
||||
app.audio.input_list.cursor,
|
||||
app.audio.input_list.scroll_offset,
|
||||
@@ -193,10 +198,8 @@ fn render_device_column(
|
||||
focused: bool,
|
||||
section_focused: bool,
|
||||
) {
|
||||
let [label_area, list_area] = Layout::vertical([
|
||||
Constraint::Length(1),
|
||||
Constraint::Min(1),
|
||||
]).areas(area);
|
||||
let [label_area, list_area] =
|
||||
Layout::vertical([Constraint::Length(1), Constraint::Min(1)]).areas(area);
|
||||
|
||||
let label_style = if focused {
|
||||
Style::new().fg(Color::Yellow).add_modifier(Modifier::BOLD)
|
||||
@@ -212,9 +215,7 @@ fn render_device_column(
|
||||
label_area,
|
||||
);
|
||||
|
||||
let items: Vec<String> = devices.iter()
|
||||
.map(|d| truncate_name(&d.name, 25))
|
||||
.collect();
|
||||
let items: Vec<String> = devices.iter().map(|d| truncate_name(&d.name, 25)).collect();
|
||||
|
||||
ListSelect::new(&items, selected_idx, cursor)
|
||||
.focused(focused)
|
||||
@@ -238,10 +239,25 @@ fn render_settings(frame: &mut Frame, app: &App, area: Rect) {
|
||||
let channels_focused = section_focused && app.audio.setting_kind == SettingKind::Channels;
|
||||
let buffer_focused = section_focused && app.audio.setting_kind == SettingKind::BufferSize;
|
||||
let polyphony_focused = section_focused && app.audio.setting_kind == SettingKind::Polyphony;
|
||||
let nudge_focused = section_focused && app.audio.setting_kind == SettingKind::Nudge;
|
||||
|
||||
let nudge_ms = app.metrics.nudge_ms;
|
||||
let nudge_label = if nudge_ms == 0.0 {
|
||||
"0 ms".to_string()
|
||||
} else {
|
||||
format!("{nudge_ms:+.1} ms")
|
||||
};
|
||||
|
||||
let rows = vec![
|
||||
Row::new(vec![
|
||||
Span::styled(if channels_focused { "> Channels" } else { " Channels" }, label_style),
|
||||
Span::styled(
|
||||
if channels_focused {
|
||||
"> Channels"
|
||||
} else {
|
||||
" Channels"
|
||||
},
|
||||
label_style,
|
||||
),
|
||||
render_selector(
|
||||
&format!("{}", app.audio.config.channels),
|
||||
channels_focused,
|
||||
@@ -250,7 +266,14 @@ fn render_settings(frame: &mut Frame, app: &App, area: Rect) {
|
||||
),
|
||||
]),
|
||||
Row::new(vec![
|
||||
Span::styled(if buffer_focused { "> Buffer" } else { " Buffer" }, label_style),
|
||||
Span::styled(
|
||||
if buffer_focused {
|
||||
"> Buffer"
|
||||
} else {
|
||||
" Buffer"
|
||||
},
|
||||
label_style,
|
||||
),
|
||||
render_selector(
|
||||
&format!("{}", app.audio.config.buffer_size),
|
||||
buffer_focused,
|
||||
@@ -259,7 +282,14 @@ fn render_settings(frame: &mut Frame, app: &App, area: Rect) {
|
||||
),
|
||||
]),
|
||||
Row::new(vec![
|
||||
Span::styled(if polyphony_focused { "> Voices" } else { " Voices" }, label_style),
|
||||
Span::styled(
|
||||
if polyphony_focused {
|
||||
"> Voices"
|
||||
} else {
|
||||
" Voices"
|
||||
},
|
||||
label_style,
|
||||
),
|
||||
render_selector(
|
||||
&format!("{}", app.audio.config.max_voices),
|
||||
polyphony_focused,
|
||||
@@ -267,6 +297,13 @@ fn render_settings(frame: &mut Frame, app: &App, area: Rect) {
|
||||
normal,
|
||||
),
|
||||
]),
|
||||
Row::new(vec![
|
||||
Span::styled(
|
||||
if nudge_focused { "> Nudge" } else { " Nudge" },
|
||||
label_style,
|
||||
),
|
||||
render_selector(&nudge_label, nudge_focused, highlight, normal),
|
||||
]),
|
||||
Row::new(vec![
|
||||
Span::styled(" Sample rate", label_style),
|
||||
Span::styled(
|
||||
|
||||
Reference in New Issue
Block a user