fix: keep horizontal mixer entries on one row

Render horizontal separators as inline labeled divider columns and keep all faders and separators on one baseline. Use a selection-centered width viewport instead of breaking groups onto additional rows.\n\nTests: cargo fmt --all -- --check\nTests: cargo check --workspace --all-targets --all-features\nTests: cargo test --workspace --all-targets --all-features\nTests: cargo test --workspace --doc --all-features\nTests: cargo clippy --workspace --all-targets --all-features -- -D warnings\nTests: cargo build --workspace --release --all-features\nTests: cargo check --workspace\nTests: cargo check --workspace --no-default-features\nTests: cargo check -p midi --no-default-features --features midir\nTests: cargo check -p volume_lib --no-default-features --features pulse
This commit is contained in:
Dandaedre 2026-10-15 22:47:34 +02:00
parent 28c2d6ce90
commit e371abea4b
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
4 changed files with 74 additions and 133 deletions

View File

@ -84,9 +84,11 @@ default MIDI controller, restore individual hidden faders, inspect backend and
MIDI-device state, and save the server-owned draft. Save both activates the
validated configuration and persists it; there is no separate Apply step.
Unassigned volume and mute controls inherit that default for MIDI learn.
Vertical mode keeps the stacked card appearance; both modes keep separators
full-width. The old `Shift+h` hidden-list mode and pipe-delimited object editors
are no longer used.
Vertical mode keeps the stacked card appearance and full-width separator rows.
Horizontal mode keeps every fader and labeled separator divider in one
continuous row, scrolling the visible columns around the selection when needed.
The old `Shift+h` hidden-list mode and pipe-delimited object editors are no
longer used.
# References

View File

@ -433,8 +433,10 @@ density. Omitted density defaults to `standard` for existing profiles. Vertical
mode keeps the stacked card layout: Slim is a single terminal row while the
other sizes retain progressively more detail. Horizontal mode uses side-by-side
console-style fader strips with bottom-up meters, state, percentage, pickup
status, and a label at the bottom; density controls strip width. Separators
remain full-width bands between groups of strips.
status, and a label at the bottom; density controls strip width. Horizontal
separators are labeled inline divider columns so every layout entry stays in a
single row, with the selected entry kept inside the width-bounded viewport.
Vertical separators remain full-width rows between stacked cards.
The selected main-list entry can be moved directly, and separators can be
added, renamed, moved, or removed. Adding or renaming a separator uses a

View File

@ -382,8 +382,9 @@ Dependencies: M8, M2, M1.
Hidden restoration now lives in the Config settings page rather than a
second mixer mode. Config also persists a Vertical or Horizontal mixer
orientation. Horizontal mode renders side-by-side console-style fader strips;
vertical mode keeps the stacked card layout. Separators span the display width
in either mode.
vertical mode keeps the stacked card layout. Separators are inline labeled
divider columns in Horizontal mode so entries stay on one row, and span the
display width in Vertical mode.
- [x] **M9.5 Guided fader editor:** replace pipe-delimited table commands with a
selected-fader form. Application faders edit capture field/mode/pattern;
groups select eligible application faders and show the absolute group mode;

View File

@ -2685,97 +2685,7 @@ impl<C: MixerClient> LiveTui<C> {
}
fn render_fader_strips(&self, area: Rect, buf: &mut Buffer, rows: &[MixerRow<'_>]) {
struct Band {
entries: Vec<usize>,
minimum_height: u16,
faders: bool,
}
let mut bands = Vec::new();
let mut index = 0;
while index < rows.len() {
if matches!(rows[index], MixerRow::Separator { .. }) {
bands.push(Band {
entries: vec![index],
minimum_height: 3,
faders: false,
});
index += 1;
continue;
}
let mut entries = Vec::new();
while index < rows.len() && matches!(rows[index], MixerRow::Fader { .. }) {
entries.push(index);
index += 1;
}
bands.push(Band {
entries,
minimum_height: 8,
faders: true,
});
}
let selected = self.selected.min(rows.len().saturating_sub(1));
let selected_band = bands
.iter()
.position(|band| band.entries.contains(&selected))
.unwrap_or(0);
let mut start = selected_band;
let mut minimum = bands[selected_band].minimum_height.min(area.height);
while start > 0 && minimum.saturating_add(bands[start - 1].minimum_height) <= area.height {
start -= 1;
minimum = minimum.saturating_add(bands[start].minimum_height);
}
let mut end = selected_band + 1;
while end < bands.len() && minimum.saturating_add(bands[end].minimum_height) <= area.height
{
minimum = minimum.saturating_add(bands[end].minimum_height);
end += 1;
}
let fader_bands = bands[start..end]
.iter()
.filter(|band| band.faders)
.count()
.max(1);
let extra = area.height.saturating_sub(minimum);
let extra_per_fader = extra / u16::try_from(fader_bands).unwrap_or(u16::MAX).max(1);
let mut extra_remainder = extra % u16::try_from(fader_bands).unwrap_or(u16::MAX).max(1);
let mut y = area.y;
for band in &bands[start..end] {
let mut height = band.minimum_height;
if band.faders {
height = height.saturating_add(extra_per_fader);
if extra_remainder > 0 {
height = height.saturating_add(1);
extra_remainder -= 1;
}
}
height = height.min(area.bottom().saturating_sub(y));
if height == 0 {
break;
}
let band_area = Rect::new(area.x, y, area.width, height);
if band.faders {
self.render_fader_strip_band(band_area, buf, rows, &band.entries);
} else if let Some(entry) = band.entries.first() {
self.render_fader_strip_separator(
band_area,
buf,
&rows[*entry],
*entry == self.selected,
);
}
y = y.saturating_add(height);
}
}
fn render_fader_strip_band(
&self,
area: Rect,
buf: &mut Buffer,
rows: &[MixerRow<'_>],
entries: &[usize],
) {
let width = |row: &MixerRow<'_>| match row {
MixerRow::Fader {
density: FaderDensity::Slim,
@ -2789,40 +2699,42 @@ impl<C: MixerClient> LiveTui<C> {
density: FaderDensity::Thick,
..
} => 22,
MixerRow::Separator { .. } => 0,
MixerRow::Separator { label, .. } => u16::try_from(label.chars().count())
.unwrap_or(u16::MAX)
.saturating_add(2)
.clamp(8, 18),
};
let selected_position = entries
.iter()
.position(|entry| *entry == self.selected)
.unwrap_or(0);
let mut first = selected_position;
let mut used = width(&rows[entries[selected_position]]).min(area.width);
while first > 0 {
let candidate = width(&rows[entries[first - 1]]);
let mut start = selected;
let mut used = width(&rows[selected]).min(area.width);
while start > 0 {
let candidate = width(&rows[start - 1]);
if used.saturating_add(candidate) > area.width {
break;
}
first -= 1;
start -= 1;
used = used.saturating_add(candidate);
}
let mut last = selected_position + 1;
while last < entries.len() {
let candidate = width(&rows[entries[last]]);
let mut end = selected + 1;
while end < rows.len() {
let candidate = width(&rows[end]);
if used.saturating_add(candidate) > area.width {
break;
}
used = used.saturating_add(candidate);
last += 1;
end += 1;
}
let mut x = area.x.saturating_add(area.width.saturating_sub(used) / 2);
for entry in &entries[first..last] {
let strip_width = width(&rows[*entry]).min(area.right().saturating_sub(x));
self.render_fader_strip(
Rect::new(x, area.y, strip_width, area.height),
buf,
&rows[*entry],
*entry == self.selected,
);
for (index, row) in rows.iter().enumerate().take(end).skip(start) {
let strip_width = width(row).min(area.right().saturating_sub(x));
let strip_area = Rect::new(x, area.y, strip_width, area.height);
match row {
MixerRow::Fader { .. } => {
self.render_fader_strip(strip_area, buf, row, index == self.selected);
}
MixerRow::Separator { .. } => {
self.render_fader_strip_separator(strip_area, buf, row, index == self.selected);
}
}
x = x.saturating_add(strip_width);
}
}
@ -2838,19 +2750,34 @@ impl<C: MixerClient> LiveTui<C> {
return;
};
let theme = self.theme.palette();
Paragraph::new(format!("── {label} ──"))
.alignment(Alignment::Center)
.style(if selected {
Style::default().fg(theme.accent).bold()
} else {
Style::default().fg(theme.muted)
})
.block(Block::bordered().border_style(if selected {
Style::default().fg(theme.accent)
} else {
Style::default().fg(theme.muted)
}))
.render(area, buf);
let style = if selected {
Style::default().fg(theme.accent).bold()
} else {
Style::default().fg(theme.muted)
};
let divider_x = area.x.saturating_add(area.width / 2);
for y in area.y..area.bottom().saturating_sub(1) {
if let Some(cell) = buf.cell_mut((divider_x, y)) {
cell.set_symbol("│");
cell.set_style(style);
}
}
if area.height > 0 {
Paragraph::new(*label)
.alignment(Alignment::Center)
.style(if selected {
Style::default()
.fg(theme.header_foreground)
.bg(theme.accent)
.bold()
} else {
style
})
.render(
Rect::new(area.x, area.bottom().saturating_sub(1), area.width, 1),
buf,
);
}
}
fn render_fader_strip(&self, area: Rect, buf: &mut Buffer, row: &MixerRow<'_>, selected: bool) {
@ -3995,7 +3922,7 @@ mod tests {
}
#[test]
fn horizontal_mixer_renders_side_by_side_fader_strips() {
fn horizontal_mixer_keeps_faders_and_separators_on_one_row() {
let mut snapshot = DemoClient::default().view();
let mut second = snapshot.items[0].clone();
snapshot.items[0].id.id = "music".into();
@ -4024,6 +3951,10 @@ mod tests {
hidden: false,
density: FaderDensity::Standard,
},
MixerLayoutEntry::Separator {
id: "players".into(),
label: "Players".into(),
},
MixerLayoutEntry::Fader {
fader: "browser-fader".into(),
hidden: false,
@ -4045,11 +3976,16 @@ mod tests {
.collect::<Vec<_>>();
let music_row = rows.iter().position(|row| row.contains("Music")).unwrap();
let separator_row = rows.iter().position(|row| row.contains("Players")).unwrap();
let browser_row = rows.iter().position(|row| row.contains("Browser")).unwrap();
assert_eq!(
music_row, browser_row,
"strip labels belong on one baseline"
);
assert_eq!(
separator_row, browser_row,
"inline separators must not start another horizontal row"
);
assert!(rows.iter().filter(|row| row.contains('█')).count() >= 3);
}