fix(slint): SongCard title elides at exact available width in every NPB layout

The now-playing title elided early (the wrapping Rectangle content-sized to the
meta line) and, when forced to width:100%, overflowed into the audio stamp.
Replace both with an explicit `title-avail` width = card width - cover - art-gap
- (in-card stamp + 4px, when present), mirroring the inner row's width formula.
The title now elides at precisely the free space in New / Classic / Small at any
window size (the formula is parametric on root.width + has-stamp + show-art, so
Big inherits it), leaving the intended ~4px gap before the stamp and never
overlapping it.

cc
This commit is contained in:
vicrodh committed 2026-06-15 02:08:34 -06:00
1 parent 62449c757d
commit 2acf53ed20
1 file changed
+23
+23
View File
@@ -168,6 +168,21 @@ export component SongCard inherits Rectangle {
: (root.compact-stamp ? (root.narrow ? 94px : 104px) : 140px);
property <bool> has-stamp: root.show-badges && NowPlayingState.has-track;
// Exact horizontal space available to the title / meta text. Computed from
// the card width minus the cover (art-size + art→text gap) and — when the
// audio stamp is rendered INSIDE the card (New/Classic) — its reserved width
// + the 4px gap, mirroring the inner row's width formula. Used as the title
// Text's explicit width so it elides at PRECISELY the available space in
// every layout (New/Classic/Small) and window size. Relying on layout
// auto-fill failed both ways: a bare Rectangle content-sized too narrow
// (truncated early), and width:100% became unbounded (overflowed the stamp).
// Small has no in-card stamp and its time column lives OUTSIDE the SongCard,
// so root.width already excludes it — the same formula covers it.
property <length> title-avail: Math.max(0px,
root.width - 2 * root.pad
- (root.has-stamp ? root.stamp-w + 4px : 0px)
- (root.show-art ? root.art-size + root.art-text-gap : 0px));
background: root.glass ? Theme.surface-elevated : transparent;
border-radius: root.glass ? 8px : 0px;
// No border — keeps the album art flush with the card (Tauri parity).
@@ -288,6 +303,10 @@ export component SongCard inherits Rectangle {
spacing: 1px;
alignment: center;
Rectangle {
// Explicit available width (see `title-avail`): the title elides
// at exactly the free space — never content-sized too narrow, and
// never overflowing into the audio stamp.
width: root.title-avail;
tc-title := Text {
width: 100%;
text: NowPlayingState.has-track
@@ -396,6 +415,10 @@ export component SongCard inherits Rectangle {
// this path unchanged. The text-center path above (Small bar) is the
// tight inner-block alternative.
if !root.text-center: Rectangle {
// Explicit available width (see `title-avail`) so the title elides at
// exactly the free space in New/Classic — never content-sized narrow,
// never overflowing into the in-card audio stamp.
width: root.title-avail;
title-txt := Text {
width: 100%;
text: NowPlayingState.has-track