Size the now-playing info block to its content, spectrum fills the rest
Instead of a fixed info-block height, derive it from the number of info lines (4 with a track, 3 without) plus the border, and let the spectrum take all remaining rows. Both regions now size themselves: the info block is exactly as tall as it needs, the bars fill everything left. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b3fec6d3c0
commit
bdfc0ec29c
|
|
@ -17,10 +17,6 @@ use super::{COLOR_PRIMARY, COLOR_SECONDARY};
|
||||||
/// Vertical block glyphs by eighths, index 0 = empty, 8 = full cell.
|
/// Vertical block glyphs by eighths, index 0 = empty, 8 = full cell.
|
||||||
const BLOCKS: [char; 9] = [' ', '▁', '▂', '▃', '▄', '▅', '▆', '▇', '█'];
|
const BLOCKS: [char; 9] = [' ', '▁', '▂', '▃', '▄', '▅', '▆', '▇', '█'];
|
||||||
|
|
||||||
/// Fixed height of the now-playing info block (4 text lines + border)
|
|
||||||
/// when the spectrum is shown; the spectrum then fills the rest.
|
|
||||||
const INFO_HEIGHT: u16 = 6;
|
|
||||||
|
|
||||||
/// Renders `bins` as full-height vertical bars filling a `width`×`height`
|
/// Renders `bins` as full-height vertical bars filling a `width`×`height`
|
||||||
/// area: one `Line` per row, top row first. Each column maps to a bin;
|
/// area: one `Line` per row, top row first. Each column maps to a bin;
|
||||||
/// its level in `[0, 1]` fills from the bottom, using partial block
|
/// its level in `[0, 1]` fills from the bottom, using partial block
|
||||||
|
|
@ -125,13 +121,16 @@ impl NowPlaying {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render(&self, f: &mut Frame, area: Rect) {
|
pub fn render(&self, f: &mut Frame, area: Rect) {
|
||||||
// With the spectrum on, the info block takes a fixed height, the
|
// With the spectrum on, the info block takes exactly the height
|
||||||
// progress a fixed row, and the spectrum fills whatever is left
|
// its content needs, the progress a fixed row, and the spectrum
|
||||||
// (`Min(0)`) so the bars are as tall as the pane allows. With it
|
// fills whatever is left (`Min(0)`) — so both size themselves and
|
||||||
// off, the info block fills as before.
|
// the bars are as tall as the pane allows. With it off, the info
|
||||||
|
// block fills as before.
|
||||||
|
let info_lines = if self.track.is_some() { 4 } else { 3 };
|
||||||
|
let info_height = info_lines + 2; // + top and bottom border
|
||||||
let constraints = if self.spectrum_enabled {
|
let constraints = if self.spectrum_enabled {
|
||||||
vec![
|
vec![
|
||||||
Constraint::Length(INFO_HEIGHT),
|
Constraint::Length(info_height),
|
||||||
Constraint::Length(1),
|
Constraint::Length(1),
|
||||||
Constraint::Min(0),
|
Constraint::Min(0),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue