From 4d1cb4b4d243ee24063349a6b87360244368ff19 Mon Sep 17 00:00:00 2001 From: Junaid Irfan Date: Sun, 22 Nov 2026 12:44:14 -0500 Subject: [PATCH 1/2] Hide the cover while it re-encodes after a zoom, instead of showing it at the old size --- src/app/extras.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/app/extras.rs b/src/app/extras.rs index b991d56..5517ef0 100644 --- a/src/app/extras.rs +++ b/src/app/extras.rs @@ -549,7 +549,10 @@ impl App { np.set_protocol_type(p.protocol_type()); self.img_picker = Some(np); if let Some(a) = self.art.as_mut() { - a.size = (0, 0); // no longer matches art_want, so refresh_media re-encodes (old cover stays up meanwhile) + a.size = (0, 0); // no longer matches art_want, so refresh_media re-encodes + // The old picture is sized in old pixels: it would spill over the borders (zoom out) or + // sit small in the corner (zoom in) and leave bits behind, so show none until the new one. + a.proto = None; } } From e8046482bd95841f2923b8dc6cfe576dbe1ba2a0 Mon Sep 17 00:00:00 2001 From: Junaid Irfan Date: Sun, 22 Nov 2026 13:09:24 -0500 Subject: [PATCH 2/2] Frame the cover like the panels and fill the frame exactly --- src/app/extras.rs | 5 +++-- src/ui.rs | 24 +++++++++++++++--------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/app/extras.rs b/src/app/extras.rs index 5517ef0..6363db6 100644 --- a/src/app/extras.rs +++ b/src/app/extras.rs @@ -78,10 +78,11 @@ fn now_ms() -> u64 { fn encode_art(picker: &Picker, bytes: &[u8], size: (u16, u16)) -> Result<(Protocol, Option<[u8; 3]>), String> { let img = image::load_from_memory(bytes).map_err(|e| e.to_string())?; let tint = Some(theme::cover_tint(&img)); - // Shrink with a cheap filter first: the cover is 640 px, the target is ~a few hundred. + // Fill the cells exactly (cropping the few pixels the cell grid isn't square by), so the + // cover meets its frame on every side instead of leaving a gap on one. let fs = picker.font_size(); let (w, h) = (size.0 as u32 * fs.width as u32, size.1 as u32 * fs.height as u32); - let img = if img.width() > w * 2 || img.height() > h * 2 { img.thumbnail(w * 2, h * 2) } else { img }; + let img = img.resize_to_fill(w.max(1), h.max(1), image::imageops::FilterType::Triangle); picker .new_protocol(img, Size::new(size.0, size.1), Resize::Fit(Some(FilterType::Triangle))) .map(|p| (p, tint)) diff --git a/src/ui.rs b/src/ui.rs index 4646485..40da073 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -93,13 +93,17 @@ pub fn draw(f: &mut Frame, app: &mut App) { let side_w = if f.area().width < 70 && app.focus != Focus::Side { 0 } else { (f.area().width / 4).clamp(18, 32) }; let [side, main] = Layout::horizontal([Constraint::Length(side_w), Constraint::Min(20)]).areas(body); - // sidebar, with the cover under it when there's room + // sidebar, with the cover under it when there's room, framed like the panels so its + // edges line up with theirs (a picture can't start mid-cell the way a border line does) let art_rows = art_rows(app, side); - app.art_want = art_rows.map(|r| (side.width, r)); + app.art_want = art_rows.map(|r| (side.width - 2, r)); let (side, art_area) = match art_rows { Some(r) => { - let [s, a] = Layout::vertical([Constraint::Min(6), Constraint::Length(r)]).areas(side); - (s, Some(a)) + let [s, a] = Layout::vertical([Constraint::Min(6), Constraint::Length(r + 2)]).areas(side); + let frame = Block::bordered().border_type(BorderType::Rounded).border_style(Style::new().dim()); + let inner = frame.inner(a); + f.render_widget(frame, a); + (s, Some(inner)) } None => (side, None), }; @@ -186,16 +190,18 @@ pub fn draw_splash(f: &mut Frame, playlists: &[String]) { f.render_widget(Paragraph::new(" Connecting…").dim(), bottom); } -/// Height (in rows) for a square cover the width of the sidebar, if the sidebar is tall -/// enough to still show a useful list above it. +/// Rows for a square cover inside a frame the width of the sidebar (rounded, so the cover +/// fills it with the least cropped), if the sidebar is tall enough to still show a useful +/// list above it. fn art_rows(app: &App, side: Rect) -> Option { let picker = app.img_picker.as_ref()?; - if !app.art_on || app.now.as_ref()?.art.is_none() { + if !app.art_on || app.now.as_ref()?.art.is_none() || side.width < 3 { return None; } let fs = picker.font_size(); - let rows = (side.width as u32 * fs.width as u32 / fs.height.max(1) as u32) as u16; - (rows >= 4 && side.height >= rows + 10).then_some(rows) + let (w, fh) = ((side.width - 2) as u32 * fs.width as u32, fs.height.max(1) as u32); + let rows = ((w + fh / 2) / fh) as u16; + (rows >= 4 && side.height >= rows + 12).then_some(rows) } fn draw_table(f: &mut Frame, app: &mut App, main: Rect) {