feat: render horizontal mixer as fader strips
Render the horizontal mixer as side-by-side console-style strips with bottom-up meters while preserving the stacked-card vertical layout. Document the orientation and density behavior.\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:
parent
556e0bdfe1
commit
a90a38b89e
13
README.md
13
README.md
|
|
@ -54,17 +54,20 @@ mode, and separate controller, Learn MIDI, and Unlearn MIDI actions for both
|
|||
volume and mute. Learning opens a waiting popup and captures the next supported
|
||||
fader movement or button press from the selected controller. The editor also
|
||||
provides per-fader Size (`Slim`, `Standard`, or `Thick`) and visibility. Slim
|
||||
faders occupy one terminal row; Standard remains the compatible default. The
|
||||
separator name is entered in a centered popup for both add and rename actions.
|
||||
faders occupy one terminal row in Vertical mode; Standard remains the compatible
|
||||
default. Horizontal mode presents side-by-side fader strips with bottom-up
|
||||
meters, status, percentage, and bottom labels, with Size controlling strip
|
||||
width. The separator name is entered in a centered popup for both add and rename
|
||||
actions.
|
||||
The Config tab is a settings/status page: change the profile theme, switch the
|
||||
persisted mixer layout between Vertical and Horizontal, select the profile's
|
||||
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.
|
||||
Horizontal mode packs fader cards side by side and keeps 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; both modes keep separators
|
||||
full-width. The old `Shift+h` hidden-list mode and pipe-delimited object editors
|
||||
are no longer used.
|
||||
|
||||
# References
|
||||
|
||||
|
|
|
|||
|
|
@ -415,11 +415,12 @@ MIDI bindings, or saved state. Profiles without an explicit layout synthesize
|
|||
one visible entry for every declared fader in declaration order. Validation
|
||||
rejects duplicate layout IDs, duplicate fader references, and dangling fader
|
||||
references. Each fader layout entry also stores a `slim`, `standard`, or `thick`
|
||||
vertical density. Omitted density defaults to `standard` for existing profiles;
|
||||
`slim` is a single terminal row while the other modes retain progressively more
|
||||
vertical detail. The profile-level `ui.mixer_orientation` is `vertical` by
|
||||
default for compatibility. `horizontal` packs fader cards into display-width
|
||||
rows while separators remain full-width boundaries.
|
||||
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.
|
||||
|
||||
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
|
||||
|
|
|
|||
13
task.md
13
task.md
|
|
@ -373,8 +373,9 @@ Dependencies: M8, M2, M1.
|
|||
reusing the mixer status line.
|
||||
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 packs faders side by side while separators span
|
||||
the display width.
|
||||
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.
|
||||
- [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;
|
||||
|
|
@ -391,10 +392,10 @@ Dependencies: M8, M2, M1.
|
|||
relearning atomically replaces only the chosen action, and validation
|
||||
conflicts retain the draft. Visibility uses the same form.
|
||||
The form also persists a per-fader Slim, Standard, or Thick size in the mixer
|
||||
layout. Existing profiles default to Standard, while Slim renders in one
|
||||
terminal row. Config stores a validated default controller; unassigned volume
|
||||
and mute learn actions inherit it while explicit bindings keep their selected
|
||||
surface.
|
||||
layout. Existing profiles default to Standard. Slim renders in one terminal
|
||||
row for vertical cards and as a narrower strip for horizontal faders. Config
|
||||
stores a validated default controller; unassigned volume and mute learn actions
|
||||
inherit it while explicit bindings keep their selected surface.
|
||||
- [ ] **M9.6 Single-screen configuration workflow:** remove the normalized
|
||||
Config table browser once all its operations are reachable from the mixer,
|
||||
keep Save and draft/durable status visible, and expose hidden-item
|
||||
|
|
|
|||
562
tui/src/lib.rs
562
tui/src/lib.rs
|
|
@ -2560,9 +2560,314 @@ impl<C: MixerClient> LiveTui<C> {
|
|||
return;
|
||||
}
|
||||
if self.snapshot.configuration.mixer_orientation == MixerOrientation::Horizontal {
|
||||
self.render_horizontal_streams(area, buf, &rows);
|
||||
self.render_fader_strips(area, buf, &rows);
|
||||
return;
|
||||
}
|
||||
self.render_vertical_streams(area, buf, &rows);
|
||||
}
|
||||
|
||||
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,
|
||||
..
|
||||
} => 10,
|
||||
MixerRow::Fader {
|
||||
density: FaderDensity::Standard,
|
||||
..
|
||||
} => 16,
|
||||
MixerRow::Fader {
|
||||
density: FaderDensity::Thick,
|
||||
..
|
||||
} => 22,
|
||||
MixerRow::Separator { .. } => 0,
|
||||
};
|
||||
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]]);
|
||||
if used.saturating_add(candidate) > area.width {
|
||||
break;
|
||||
}
|
||||
first -= 1;
|
||||
used = used.saturating_add(candidate);
|
||||
}
|
||||
let mut last = selected_position + 1;
|
||||
while last < entries.len() {
|
||||
let candidate = width(&rows[entries[last]]);
|
||||
if used.saturating_add(candidate) > area.width {
|
||||
break;
|
||||
}
|
||||
used = used.saturating_add(candidate);
|
||||
last += 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,
|
||||
);
|
||||
x = x.saturating_add(strip_width);
|
||||
}
|
||||
}
|
||||
|
||||
fn render_fader_strip_separator(
|
||||
&self,
|
||||
area: Rect,
|
||||
buf: &mut Buffer,
|
||||
row: &MixerRow<'_>,
|
||||
selected: bool,
|
||||
) {
|
||||
let MixerRow::Separator { label, .. } = row else {
|
||||
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);
|
||||
}
|
||||
|
||||
fn render_fader_strip(&self, area: Rect, buf: &mut Buffer, row: &MixerRow<'_>, selected: bool) {
|
||||
let MixerRow::Fader { item, .. } = row else {
|
||||
return;
|
||||
};
|
||||
let theme = self.theme.palette();
|
||||
let percent = item
|
||||
.gain
|
||||
.map_or(0, |gain| (gain.clamp(0.0, 1.0) * 100.0).round() as u16);
|
||||
let meter_color = if item.error.is_some() {
|
||||
theme.error
|
||||
} else if item.muted == Some(true) {
|
||||
theme.warning
|
||||
} else {
|
||||
theme.secondary
|
||||
};
|
||||
let state = if item.error.is_some() {
|
||||
"ERROR"
|
||||
} else if item.gain.is_none() {
|
||||
"OFFLINE"
|
||||
} else if item.mute_mixed || item.gain_mixed {
|
||||
"MIXED"
|
||||
} else if item.muted == Some(true) {
|
||||
"MUTED"
|
||||
} else if !item.writable {
|
||||
"READ ONLY"
|
||||
} else if item.pending {
|
||||
"PENDING"
|
||||
} else {
|
||||
"LIVE"
|
||||
};
|
||||
if area.height < 6 || area.width < 8 {
|
||||
let label = if state == "LIVE" {
|
||||
format!(
|
||||
"{} {} {percent}%",
|
||||
if selected { "▶" } else { " " },
|
||||
item.label
|
||||
)
|
||||
} else {
|
||||
format!("{state} {percent}%")
|
||||
};
|
||||
Gauge::default()
|
||||
.gauge_style(Style::default().bg(theme.meter_track).fg(meter_color))
|
||||
.percent(percent)
|
||||
.label(label)
|
||||
.render(area, buf);
|
||||
return;
|
||||
}
|
||||
|
||||
let pickup = match item.pickup {
|
||||
Some(PickupStatus::Unavailable) => "pickup: unavailable",
|
||||
Some(PickupStatus::Waiting) => "pickup: waiting",
|
||||
Some(PickupStatus::Tracking) => "pickup: tracking",
|
||||
Some(PickupStatus::Mixed) => "pickup: mixed",
|
||||
None => "",
|
||||
};
|
||||
let footer_height = if area.height >= 9 { 4 } else { 3 };
|
||||
let meter_height = area.height.saturating_sub(footer_height);
|
||||
let meter_width = area.width.saturating_sub(4).clamp(3, 7);
|
||||
let meter_area = Rect::new(
|
||||
area.x + area.width.saturating_sub(meter_width) / 2,
|
||||
area.y,
|
||||
meter_width,
|
||||
meter_height,
|
||||
);
|
||||
let meter_block = Block::bordered().border_style(if selected {
|
||||
Style::default().fg(theme.accent)
|
||||
} else {
|
||||
Style::default().fg(theme.muted)
|
||||
});
|
||||
let inner = meter_block.inner(meter_area);
|
||||
meter_block.render(meter_area, buf);
|
||||
let filled = u32::from(inner.height)
|
||||
.saturating_mul(u32::from(percent))
|
||||
.div_ceil(100) as u16;
|
||||
for y in inner.y..inner.bottom() {
|
||||
let is_filled = inner.bottom().saturating_sub(y) <= filled;
|
||||
for x in inner.x..inner.right() {
|
||||
if let Some(cell) = buf.cell_mut((x, y)) {
|
||||
cell.set_symbol(if is_filled { "█" } else { "░" });
|
||||
cell.set_style(
|
||||
Style::default()
|
||||
.fg(if is_filled { meter_color } else { theme.muted })
|
||||
.bg(theme.meter_track),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let footer_y = area.bottom().saturating_sub(footer_height);
|
||||
if footer_height == 4 {
|
||||
Paragraph::new(pickup)
|
||||
.alignment(Alignment::Center)
|
||||
.style(Style::default().fg(theme.muted))
|
||||
.render(Rect::new(area.x, footer_y, area.width, 1), buf);
|
||||
}
|
||||
Paragraph::new(state)
|
||||
.alignment(Alignment::Center)
|
||||
.style(Style::default().fg(if state == "ERROR" {
|
||||
theme.error
|
||||
} else if state == "MUTED" {
|
||||
theme.warning
|
||||
} else {
|
||||
theme.foreground
|
||||
}))
|
||||
.render(
|
||||
Rect::new(area.x, area.bottom().saturating_sub(3), area.width, 1),
|
||||
buf,
|
||||
);
|
||||
Paragraph::new(format!("{percent}%"))
|
||||
.alignment(Alignment::Center)
|
||||
.style(Style::default().fg(theme.foreground).bold())
|
||||
.render(
|
||||
Rect::new(area.x, area.bottom().saturating_sub(2), area.width, 1),
|
||||
buf,
|
||||
);
|
||||
Paragraph::new(item.label.as_str())
|
||||
.alignment(Alignment::Center)
|
||||
.style(if selected {
|
||||
Style::default()
|
||||
.fg(theme.header_foreground)
|
||||
.bg(theme.accent)
|
||||
.bold()
|
||||
} else {
|
||||
Style::default().fg(theme.accent).bold()
|
||||
})
|
||||
.render(
|
||||
Rect::new(area.x, area.bottom().saturating_sub(1), area.width, 1),
|
||||
buf,
|
||||
);
|
||||
}
|
||||
|
||||
fn render_vertical_streams(&self, area: Rect, buf: &mut Buffer, rows: &[MixerRow<'_>]) {
|
||||
let theme = self.theme.palette();
|
||||
let selected = self.selected.min(rows.len().saturating_sub(1));
|
||||
let mut start = selected;
|
||||
let mut occupied = rows[selected].height();
|
||||
|
|
@ -2684,184 +2989,6 @@ impl<C: MixerClient> LiveTui<C> {
|
|||
.render(meter, buf);
|
||||
}
|
||||
}
|
||||
|
||||
fn render_horizontal_streams(&self, area: Rect, buf: &mut Buffer, rows: &[MixerRow<'_>]) {
|
||||
struct Band {
|
||||
entries: Vec<usize>,
|
||||
height: u16,
|
||||
}
|
||||
|
||||
let columns = usize::from((area.width / 30).max(1));
|
||||
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],
|
||||
height: rows[index].height(),
|
||||
});
|
||||
index += 1;
|
||||
continue;
|
||||
}
|
||||
let mut entries = Vec::new();
|
||||
let mut height = 1;
|
||||
while index < rows.len()
|
||||
&& entries.len() < columns
|
||||
&& matches!(rows[index], MixerRow::Fader { .. })
|
||||
{
|
||||
height = height.max(rows[index].height());
|
||||
entries.push(index);
|
||||
index += 1;
|
||||
}
|
||||
bands.push(Band { entries, height });
|
||||
}
|
||||
|
||||
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 occupied = bands[selected_band].height;
|
||||
while start > 0 {
|
||||
let previous = bands[start - 1].height;
|
||||
if occupied.saturating_add(previous) > area.height {
|
||||
break;
|
||||
}
|
||||
start -= 1;
|
||||
occupied = occupied.saturating_add(previous);
|
||||
}
|
||||
|
||||
let mut y = area.y;
|
||||
for band in bands.iter().skip(start) {
|
||||
let remaining = area.bottom().saturating_sub(y);
|
||||
if remaining == 0 {
|
||||
break;
|
||||
}
|
||||
let height = band.height.min(remaining);
|
||||
if band.entries.len() == 1
|
||||
&& matches!(rows[band.entries[0]], MixerRow::Separator { .. })
|
||||
{
|
||||
self.render_horizontal_entry(
|
||||
&rows[band.entries[0]],
|
||||
Rect::new(area.x, y, area.width, height),
|
||||
band.entries[0] == self.selected,
|
||||
buf,
|
||||
);
|
||||
} else {
|
||||
let count = u16::try_from(band.entries.len()).unwrap_or(u16::MAX).max(1);
|
||||
let width = area.width / count;
|
||||
for (column, entry) in band.entries.iter().enumerate() {
|
||||
let column = u16::try_from(column).unwrap_or(u16::MAX);
|
||||
let x = area.x.saturating_add(width.saturating_mul(column));
|
||||
let card_width = if column + 1 == count {
|
||||
area.right().saturating_sub(x)
|
||||
} else {
|
||||
width
|
||||
};
|
||||
self.render_horizontal_entry(
|
||||
&rows[*entry],
|
||||
Rect::new(x, y, card_width, rows[*entry].height().min(height)),
|
||||
*entry == self.selected,
|
||||
buf,
|
||||
);
|
||||
}
|
||||
}
|
||||
y = y.saturating_add(height);
|
||||
}
|
||||
}
|
||||
|
||||
fn render_horizontal_entry(
|
||||
&self,
|
||||
row: &MixerRow<'_>,
|
||||
area: Rect,
|
||||
selected: bool,
|
||||
buf: &mut Buffer,
|
||||
) {
|
||||
let theme = self.theme.palette();
|
||||
let MixerRow::Fader { item, density, .. } = row else {
|
||||
let MixerRow::Separator { label, .. } = row else {
|
||||
return;
|
||||
};
|
||||
if area.height < 2 {
|
||||
return;
|
||||
}
|
||||
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);
|
||||
return;
|
||||
};
|
||||
let percent = item
|
||||
.gain
|
||||
.map_or(0, |gain| (gain.clamp(0.0, 1.0) * 100.0).round() as u16);
|
||||
let state = if item.gain.is_none() {
|
||||
"OFFLINE"
|
||||
} else if item.mute_mixed || item.gain_mixed {
|
||||
"MIXED"
|
||||
} else if item.muted == Some(true) {
|
||||
"MUTED"
|
||||
} else if !item.writable {
|
||||
"READ ONLY"
|
||||
} else {
|
||||
""
|
||||
};
|
||||
let meter_style = Style::default()
|
||||
.bg(theme.meter_track)
|
||||
.fg(if item.error.is_some() {
|
||||
theme.error
|
||||
} else if item.muted == Some(true) {
|
||||
theme.warning
|
||||
} else {
|
||||
theme.secondary
|
||||
});
|
||||
let label = item.error.as_deref().map_or_else(
|
||||
|| format!("{percent}% {state}"),
|
||||
|error| format!("ERROR: {error}"),
|
||||
);
|
||||
if *density == FaderDensity::Slim {
|
||||
Gauge::default()
|
||||
.gauge_style(meter_style)
|
||||
.percent(percent)
|
||||
.label(format!(
|
||||
"{} {} {label}",
|
||||
if selected { "▶" } else { " " },
|
||||
item.label
|
||||
))
|
||||
.render(area, buf);
|
||||
return;
|
||||
}
|
||||
if area.height < 2 {
|
||||
return;
|
||||
}
|
||||
let block = Block::bordered()
|
||||
.title(format!(
|
||||
"{} {}",
|
||||
if selected { "▶" } else { " " },
|
||||
item.label
|
||||
))
|
||||
.border_style(if selected {
|
||||
Style::default().fg(theme.accent)
|
||||
} else {
|
||||
Style::default().fg(theme.muted)
|
||||
});
|
||||
let meter = block.inner(area);
|
||||
block.render(area, buf);
|
||||
Gauge::default()
|
||||
.gauge_style(meter_style)
|
||||
.percent(percent)
|
||||
.label(label)
|
||||
.render(meter, buf);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
@ -3661,6 +3788,7 @@ mod tests {
|
|||
{
|
||||
*density = FaderDensity::Slim;
|
||||
}
|
||||
app.snapshot.configuration.mixer_orientation = MixerOrientation::Vertical;
|
||||
let area = Rect::new(0, 0, 80, 1);
|
||||
let mut buffer = Buffer::empty(area);
|
||||
app.render_streams(area, &mut buffer);
|
||||
|
|
@ -3674,7 +3802,61 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn horizontal_mixer_renders_faders_side_by_side() {
|
||||
fn vertical_mixer_keeps_stacked_fader_cards() {
|
||||
let mut snapshot = DemoClient::default().view();
|
||||
let mut second = snapshot.items[0].clone();
|
||||
snapshot.items[0].id.id = "music".into();
|
||||
snapshot.items[0].label = "Music".into();
|
||||
second.id.id = "browser".into();
|
||||
second.label = "Browser".into();
|
||||
snapshot.items.push(second);
|
||||
snapshot.configuration.mixer_orientation = MixerOrientation::Vertical;
|
||||
snapshot.configuration.faders = vec![
|
||||
ConfiguredFader {
|
||||
id: "music-fader".into(),
|
||||
target: snapshot.items[0].id.clone(),
|
||||
pickup: true,
|
||||
pickup_tolerance: 0.02,
|
||||
},
|
||||
ConfiguredFader {
|
||||
id: "browser-fader".into(),
|
||||
target: snapshot.items[1].id.clone(),
|
||||
pickup: true,
|
||||
pickup_tolerance: 0.02,
|
||||
},
|
||||
];
|
||||
snapshot.configuration.mixer_layout = vec![
|
||||
MixerLayoutEntry::Fader {
|
||||
fader: "music-fader".into(),
|
||||
hidden: false,
|
||||
density: FaderDensity::Standard,
|
||||
},
|
||||
MixerLayoutEntry::Fader {
|
||||
fader: "browser-fader".into(),
|
||||
hidden: false,
|
||||
density: FaderDensity::Standard,
|
||||
},
|
||||
];
|
||||
let app = LiveTui::new(LayoutClient {
|
||||
snapshot,
|
||||
edits: Arc::new(Mutex::new(Vec::new())),
|
||||
})
|
||||
.unwrap();
|
||||
let area = Rect::new(0, 0, 80, 8);
|
||||
let mut buffer = Buffer::empty(area);
|
||||
app.render_streams(area, &mut buffer);
|
||||
let rows = buffer
|
||||
.content
|
||||
.chunks(usize::from(area.width))
|
||||
.map(|row| row.iter().map(|cell| cell.symbol()).collect::<String>())
|
||||
.collect::<Vec<_>>();
|
||||
let music_row = rows.iter().position(|row| row.contains("Music")).unwrap();
|
||||
let browser_row = rows.iter().position(|row| row.contains("Browser")).unwrap();
|
||||
assert_ne!(music_row, browser_row, "vertical cards remain stacked");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn horizontal_mixer_renders_side_by_side_fader_strips() {
|
||||
let mut snapshot = DemoClient::default().view();
|
||||
let mut second = snapshot.items[0].clone();
|
||||
snapshot.items[0].id.id = "music".into();
|
||||
|
|
@ -3714,16 +3896,22 @@ mod tests {
|
|||
edits: Arc::new(Mutex::new(Vec::new())),
|
||||
})
|
||||
.unwrap();
|
||||
let area = Rect::new(0, 0, 80, 4);
|
||||
let area = Rect::new(0, 0, 50, 16);
|
||||
let mut buffer = Buffer::empty(area);
|
||||
app.render_streams(area, &mut buffer);
|
||||
let rendered = buffer
|
||||
let rows = buffer
|
||||
.content
|
||||
.iter()
|
||||
.map(|cell| cell.symbol())
|
||||
.collect::<String>();
|
||||
assert!(rendered.contains("Music"));
|
||||
assert!(rendered.contains("Browser"));
|
||||
.chunks(usize::from(area.width))
|
||||
.map(|row| row.iter().map(|cell| cell.symbol()).collect::<String>())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let music_row = rows.iter().position(|row| row.contains("Music")).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!(rows.iter().filter(|row| row.contains('█')).count() >= 3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Reference in New Issue