feat(slint): immersive responsive sizing + shared track-info block

On large windows the panels left big empty space; on small they were fine.
Make the art/covers grow to fill while keeping small-window behavior.

- AlbumReactivePanel: art cap 460->660, width frac 0.55->0.62 (grows more,
  center-anchored pulse untouched).
- StaticPanel: cap 460->640, width 0.55->0.62 (fills large windows).
- CoverflowPanel: center cover cap 440->560, width 0.42->0.52; wrap the fan +
  track-info in ONE center-aligned VerticalLayout so the composition is
  vertically balanced (kills the "covers clustered at top, empty bottom" look
  on large windows). Persistent-element model / dual repeaters / animated
  scroll / z-order all untouched — only sizing + the wrapping layout changed.
- New shared ImmersiveTrackInfo.slint (Now Playing indicator + EqualizerBars +
  title/artist/album/quality badge), standardized on Static's look; all three
  panels use it, removing three duplicated inline copies (they can't drift).

cc
This commit is contained in:
vicrodh committed 2026-06-14 04:13:01 -06:00
1 parent 25512d0d00
commit bc22362dc0
4 files changed
+216 -385

No files matched your search

@@ -37,63 +37,8 @@
// passed in as properties. `opacity:` is NEVER set on the root (it corrupts
// absolute positioning); the fade lives on the player/ModeBar chrome instead.
import { QualityBadgeFull } from "../primitives/QualityBadgeFull.slint";
import { NowPlayingState, VisualizerState, ImmersiveState } from "../state.slint";
// Four-bar "now playing" equalizer. A continuous loop driven by the global
// animation-tick() (pull-based) — NOT a Timer (a Timer does not reliably drive
// continuous animation). Each bar phase-offset mirrors the Svelte
// animation-delay / per-bar base height (lines 311-314).
component EqualizerBars inherits Rectangle {
in property <color> tint: #7c3aed;
width: 18px;
height: 14px;
// 0.8s loop (Svelte `equalize 0.8s`): tick ms -> phase 0..1.
property <float> t: Math.mod(animation-tick() / 1ms, 800.0) / 800.0;
// scaleY 0.3..1.0 sweep (Svelte keyframes 0/100% -> 0.3, 50% -> 1.0).
function wave(phase: float) -> float {
// triangle-ish sweep peaking at the half-phase, like ease-in-out.
return 0.3 + 0.7 * (0.5 - 0.5 * Math.cos((Math.mod(self.t + phase, 1.0)) * 6.283185 * 1rad));
}
HorizontalLayout {
alignment: start;
spacing: 2px;
// bar 1: delay 0.0, base 60%
Rectangle {
width: 3px;
y: parent.height - self.height;
height: parent.height * 0.6 * root.wave(0.0);
border-radius: 1px;
background: root.tint;
}
// bar 2: delay 0.2, base 100%
Rectangle {
width: 3px;
y: parent.height - self.height;
height: parent.height * 1.0 * root.wave(0.25);
border-radius: 1px;
background: root.tint;
}
// bar 3: delay 0.1, base 40%
Rectangle {
width: 3px;
y: parent.height - self.height;
height: parent.height * 0.4 * root.wave(0.125);
border-radius: 1px;
background: root.tint;
}
// bar 4: delay 0.3, base 80%
Rectangle {
width: 3px;
y: parent.height - self.height;
height: parent.height * 0.8 * root.wave(0.375);
border-radius: 1px;
background: root.tint;
}
}
}
import { ImmersiveTrackInfo } from "ImmersiveTrackInfo.slint";
export component AlbumReactivePanel inherits Rectangle {
in property <length> viewport-width: 1280px;
@@ -120,14 +65,20 @@ export component AlbumReactivePanel inherits Rectangle {
// glowOpacity = min(0.1 + globalEnergy * 1.5, 1) (Svelte line 167)
property <float> glow-opacity: Math.min(0.1 + root.global-energy * 1.5, 1.0);
// Base art box. Tauri uses `min(52vh, 460px)`, but the Slint group must also
// leave room for the metadata block + the floating player, or the quality
// badge gets clipped under the bar. So size the art so the WHOLE group
// (art*1.25 growth + spacing + info) fits the viewport height, with a width
// cap for narrow windows. Reserve = pad-top(52) + spacing(40) + info(~160) +
// player clearance(132) = 384px. Clamped to a sane 180..460px range.
// Base art box. The group must leave room for the metadata block + the
// floating player, or the quality badge gets clipped under the bar. So size
// the art so the WHOLE group (art*1.25 growth + spacing + info) fits the
// viewport height, with a width cap. Reserve = pad-top(52) + spacing(40) +
// info(~160) + player clearance(132) = 384px.
//
// RESPONSIVE: on large/tall windows the art should GROW to fill the space
// (people love big covers; the bg particles were removed, so a small art
// reads empty). The height budget `(vh-384)/1.25` already scales with the
// window; we raise the hard cap from 460 -> 660px and the width fraction
// 0.55 -> 0.62 so the art keeps growing on a big screen instead of stalling.
// The 180px floor keeps small windows safe (small was confirmed good).
property <length> base-art: Math.max(180px,
Math.min(Math.min((root.viewport-height - 384px) / 1.25, root.viewport-width * 0.55), 460px));
Math.min(Math.min((root.viewport-height - 384px) / 1.25, root.viewport-width * 0.62), 660px));
// Reactive size = base * artScale. The glow layer and the art share this
// exact size/position so the halo stays glued to the art edge (per risk).
property <length> art-size: root.base-art * root.art-scale;
@@ -211,71 +162,9 @@ export component AlbumReactivePanel inherits Rectangle {
}
}
// --- Track info ----------------------------------------------------
info-block := VerticalLayout {
alignment: center;
spacing: 6px;
// "Now Playing" indicator: equalizer bars + label. Shown only while
// playing (Svelte {#if isPlaying}).
if NowPlayingState.playing: HorizontalLayout {
alignment: center;
spacing: 8px;
padding-bottom: 8px;
VerticalLayout {
alignment: center;
EqualizerBars {
tint: #7c3aed;
}
}
Text {
text: @tr("Now Playing");
color: #7c3aed;
font-size: 12px;
font-weight: 600;
letter-spacing: 0.5px;
vertical-alignment: center;
}
}
// Track title.
Text {
text: NowPlayingState.title;
color: #ffffff;
font-size: 28px;
font-weight: 700;
horizontal-alignment: center;
overflow: elide;
}
// Artist.
Text {
text: NowPlayingState.artist;
color: #ffffffb3;
font-size: 18px;
horizontal-alignment: center;
overflow: elide;
}
// Album (italic, dimmer). Shown only when present (Svelte {#if album}).
if NowPlayingState.album != "": Text {
text: NowPlayingState.album;
color: #ffffff80;
font-size: 14px;
font-italic: true;
horizontal-alignment: center;
overflow: elide;
}
// Quality badge (Svelte QualityBadgeStatic). Centered under the text.
HorizontalLayout {
alignment: center;
padding-top: 12px;
QualityBadgeFull {
tier: NowPlayingState.quality-tier;
detail: NowPlayingState.quality-detail;
}
}
// --- Track info (shared, homologated across all 3 panels) ----------
ImmersiveTrackInfo {
equalizer-tint: #7c3aed;
}
}
}
@@ -35,56 +35,8 @@
// Math.max(lo, Math.min(hi, x)). The center card is a SEPARATE top-most instance
// (Repeater can't reorder by data) so it paints over its neighbors.
import { QualityBadgeFull } from "../primitives/QualityBadgeFull.slint";
import { NowPlayingState, QueueState } from "../state.slint";
// Four-bar "now playing" equalizer. Continuous loop driven by the global
// animation-tick() (pull-based) — NOT a Timer. Verbatim copy of the
// StaticPanel.slint EqualizerBars; duplicated on purpose so this session does
// not touch the siblings. (Follow-up: lift into a shared EqualizerBars.slint.)
component EqualizerBars inherits Rectangle {
in property <color> tint: #7c3aed;
width: 18px;
height: 14px;
property <float> t: Math.mod(animation-tick() / 1ms, 800.0) / 800.0;
function wave(phase: float) -> float {
return 0.3 + 0.7 * (0.5 - 0.5 * Math.cos((Math.mod(self.t + phase, 1.0)) * 6.283185 * 1rad));
}
HorizontalLayout {
alignment: start;
spacing: 2px;
Rectangle {
width: 3px;
y: parent.height - self.height;
height: parent.height * 0.6 * root.wave(0.0);
border-radius: 1px;
background: root.tint;
}
Rectangle {
width: 3px;
y: parent.height - self.height;
height: parent.height * 1.0 * root.wave(0.25);
border-radius: 1px;
background: root.tint;
}
Rectangle {
width: 3px;
y: parent.height - self.height;
height: parent.height * 0.4 * root.wave(0.125);
border-radius: 1px;
background: root.tint;
}
Rectangle {
width: 3px;
y: parent.height - self.height;
height: parent.height * 0.8 * root.wave(0.375);
border-radius: 1px;
background: root.tint;
}
}
}
import { ImmersiveTrackInfo } from "ImmersiveTrackInfo.slint";
// One flat coverflow card. ALL geometry is derived from `offset` (= i - scroll)
// + the stage props passed in (NEVER `parent` in the root binding). The card
@@ -179,10 +131,18 @@ export component CoverflowPanel inherits Rectangle {
background: transparent;
// --- Geometry --------------------------------------------------------
// Center cover edge (base-art = depth-0 scale). Honors the 132px player
// clearance: reserve = pad-top(52) + info + clearance(132) = 364px.
// Center cover edge (base-art = depth-0 scale). The whole composition
// (fan stage + track-info) is wrapped in ONE centered VerticalLayout below,
// so the reserve is just pad-top(52) + info(~160) + spacing(28) +
// player-clearance(132) = 372px of vertical budget for the FAN stage.
//
// RESPONSIVE: previously capped at ~440px with a 0.42 width fraction, so on a
// LARGE window the covers stayed small clustered at the top (the "tragedy").
// We raise the cap 440 -> 560px and the width fraction 0.42 -> 0.52 so the
// fan scales up to fill the space. The height budget `vh-372` already grows
// with the window. The 160px floor keeps small windows safe (small was good).
property <length> base-art: Math.max(160px,
Math.min(Math.min(root.viewport-height - 364px, root.viewport-width * 0.42), 440px));
Math.min(Math.min(root.viewport-height - 372px, root.viewport-width * 0.52), 560px));
// X spacing between adjacent depths (overlapping inward).
property <length> pitch: root.base-art * 0.42;
@@ -200,11 +160,29 @@ export component CoverflowPanel inherits Rectangle {
: NowPlayingState.artwork;
property <bool> center-has-art: root.center-art.width > 0;
// --- Cover fan stage -------------------------------------------------
Rectangle {
// --- Balanced composition: fan stage + track-info in ONE centered column.
// Previously the fan was pinned to the TOP (y=52) and the track-info to the
// BOTTOM (alignment: end), which on a large window left a huge empty band in
// the middle (the "tragedy"). Wrapping both in a single center-aligned
// VerticalLayout distributes the whole composition through the vertical band
// (between pad-top 52 and the 132px player clearance), so the fan and the
// metadata stay together and vertically centered at any window size.
VerticalLayout {
x: 0px;
y: 52px; // pad-top, matches the siblings
y: 0px;
width: root.viewport-width;
height: root.viewport-height;
padding-top: 52px;
padding-bottom: 132px;
alignment: center;
spacing: 28px;
// --- Cover fan stage -------------------------------------------------
fan-stage := Rectangle {
width: root.viewport-width;
// Fixed height holds the center cover footprint (base-art) + headroom; the
// cards center within it via stage-height. NOT stretched (a layout child
// with an explicit height keeps the cards' centering math intact).
height: root.base-art + 56px;
property <length> cx: root.viewport-width / 2;
@@ -295,75 +273,13 @@ export component CoverflowPanel inherits Rectangle {
}
}
// --- Song card below the pyramid ------------------------------------
// Reuses the StaticPanel pattern verbatim, fed by NowPlayingState. Pinned
// under the fan, respecting the 132px player clearance.
VerticalLayout {
x: 0px;
y: 0px;
width: root.viewport-width;
height: root.viewport-height;
padding-top: 52px;
padding-bottom: 132px;
alignment: end;
spacing: 6px;
info-block := VerticalLayout {
alignment: center;
spacing: 6px;
// "Now Playing" indicator — shown only while playing.
if NowPlayingState.playing: HorizontalLayout {
alignment: center;
spacing: 8px;
padding-bottom: 8px;
VerticalLayout {
alignment: center;
EqualizerBars {
tint: #7c3aed;
}
}
Text {
text: @tr("Now Playing");
color: #7c3aed;
font-size: 12px;
font-weight: 600;
letter-spacing: 0.5px;
vertical-alignment: center;
}
}
Text {
text: NowPlayingState.title;
color: #ffffff;
font-size: 28px;
font-weight: 700;
horizontal-alignment: center;
overflow: elide;
}
Text {
text: NowPlayingState.artist;
color: #ffffffb3;
font-size: 18px;
horizontal-alignment: center;
overflow: elide;
}
if NowPlayingState.album != "": Text {
text: NowPlayingState.album;
color: #ffffff80;
font-size: 14px;
font-italic: true;
horizontal-alignment: center;
overflow: elide;
}
HorizontalLayout {
alignment: center;
padding-top: 12px;
QualityBadgeFull {
tier: NowPlayingState.quality-tier;
detail: NowPlayingState.quality-detail;
}
}
// --- Track info (shared, homologated across all 3 panels) ----------
// Sits directly below the fan in the SAME centered column, so the fan +
// metadata read as one balanced group (no more bottom-stranded info).
// Homologated to Static's look/spacing so "Now Playing" no longer bites
// the fan on small windows.
ImmersiveTrackInfo {
equalizer-tint: #7c3aed;
}
}
}
@@ -0,0 +1,139 @@
// Shared immersive track-info block (Now Playing indicator + title / artist /
// album / quality badge) + the 4-bar equalizer. HOMOLOGATED look/spacing/
// position across ALL THREE foreground panels (AlbumReactive, Static, Coverflow)
// so the metadata reads identically in every mode — standardized on Static's
// version (the one the owner liked): spacing 6px, equalizer label padding-bottom
// 8px, quality badge padding-top 12px, fonts 28/18/14.
//
// Previously each panel duplicated this block (and the EqualizerBars) verbatim;
// they are lifted here so the three modes can never drift apart again.
//
// SLINT GOTCHAS honored: `parent` is NEVER read in a root binding; no `opacity:`
// on a component root; no `changed x/y/width/height` watchers; the continuous
// equalizer loop is driven by the global animation-tick() (pull-based), NOT a
// Timer.
import { QualityBadgeFull } from "../primitives/QualityBadgeFull.slint";
import { NowPlayingState } from "../state.slint";
// Four-bar "now playing" equalizer. A continuous loop driven by the global
// animation-tick() (pull-based) — NOT a Timer. Each bar phase-offset mirrors the
// Svelte animation-delay / per-bar base height.
export component EqualizerBars inherits Rectangle {
in property <color> tint: #7c3aed;
width: 18px;
height: 14px;
// 0.8s loop (Svelte `equalize 0.8s`): tick ms -> phase 0..1.
property <float> t: Math.mod(animation-tick() / 1ms, 800.0) / 800.0;
// scaleY 0.3..1.0 sweep (Svelte keyframes 0/100% -> 0.3, 50% -> 1.0).
function wave(phase: float) -> float {
return 0.3 + 0.7 * (0.5 - 0.5 * Math.cos((Math.mod(self.t + phase, 1.0)) * 6.283185 * 1rad));
}
HorizontalLayout {
alignment: start;
spacing: 2px;
// bar 1: delay 0.0, base 60%
Rectangle {
width: 3px;
y: parent.height - self.height;
height: parent.height * 0.6 * root.wave(0.0);
border-radius: 1px;
background: root.tint;
}
// bar 2: delay 0.2, base 100%
Rectangle {
width: 3px;
y: parent.height - self.height;
height: parent.height * 1.0 * root.wave(0.25);
border-radius: 1px;
background: root.tint;
}
// bar 3: delay 0.1, base 40%
Rectangle {
width: 3px;
y: parent.height - self.height;
height: parent.height * 0.4 * root.wave(0.125);
border-radius: 1px;
background: root.tint;
}
// bar 4: delay 0.3, base 80%
Rectangle {
width: 3px;
y: parent.height - self.height;
height: parent.height * 0.8 * root.wave(0.375);
border-radius: 1px;
background: root.tint;
}
}
}
// The standardized metadata block. Drop this below the artwork/fan in every
// panel; it self-centers and self-hides parts that are empty.
export component ImmersiveTrackInfo inherits VerticalLayout {
in property <color> equalizer-tint: #7c3aed;
alignment: center;
spacing: 6px;
// "Now Playing" indicator: equalizer bars + label. Shown only while playing.
if NowPlayingState.playing: HorizontalLayout {
alignment: center;
spacing: 8px;
padding-bottom: 8px;
VerticalLayout {
alignment: center;
EqualizerBars {
tint: root.equalizer-tint;
}
}
Text {
text: @tr("Now Playing");
color: root.equalizer-tint;
font-size: 12px;
font-weight: 600;
letter-spacing: 0.5px;
vertical-alignment: center;
}
}
// Track title.
Text {
text: NowPlayingState.title;
color: #ffffff;
font-size: 28px;
font-weight: 700;
horizontal-alignment: center;
overflow: elide;
}
// Artist.
Text {
text: NowPlayingState.artist;
color: #ffffffb3;
font-size: 18px;
horizontal-alignment: center;
overflow: elide;
}
// Album (italic, dimmer). Shown only when present.
if NowPlayingState.album != "": Text {
text: NowPlayingState.album;
color: #ffffff80;
font-size: 14px;
font-italic: true;
horizontal-alignment: center;
overflow: elide;
}
// Quality badge. Self-hides when tier == "". Centered under the text.
HorizontalLayout {
alignment: center;
padding-top: 12px;
QualityBadgeFull {
tier: NowPlayingState.quality-tier;
detail: NowPlayingState.quality-detail;
}
}
}
+20 -133
View File
@@ -19,79 +19,30 @@
// VerticalLayout (pad-top 52 / pad-bottom 132), the artwork image-fit cover +
// fallback, and the static art drop shadow.
import { QualityBadgeFull } from "../primitives/QualityBadgeFull.slint";
import { NowPlayingState } from "../state.slint";
// Four-bar "now playing" equalizer. A continuous loop driven by the global
// animation-tick() (pull-based) — NOT a Timer. Verbatim copy of the
// AlbumReactivePanel.slint EqualizerBars (lines 36-85); duplicated here on
// purpose so this session does not touch AlbumReactivePanel. (Follow-up: lift
// into a shared immersive/EqualizerBars.slint imported by both panels.)
component EqualizerBars inherits Rectangle {
in property <color> tint: #7c3aed;
width: 18px;
height: 14px;
// 0.8s loop (Svelte `equalize 0.8s`): tick ms -> phase 0..1.
property <float> t: Math.mod(animation-tick() / 1ms, 800.0) / 800.0;
// scaleY 0.3..1.0 sweep (Svelte keyframes 0/100% -> 0.3, 50% -> 1.0).
function wave(phase: float) -> float {
return 0.3 + 0.7 * (0.5 - 0.5 * Math.cos((Math.mod(self.t + phase, 1.0)) * 6.283185 * 1rad));
}
HorizontalLayout {
alignment: start;
spacing: 2px;
// bar 1: delay 0.0, base 60%
Rectangle {
width: 3px;
y: parent.height - self.height;
height: parent.height * 0.6 * root.wave(0.0);
border-radius: 1px;
background: root.tint;
}
// bar 2: delay 0.2, base 100%
Rectangle {
width: 3px;
y: parent.height - self.height;
height: parent.height * 1.0 * root.wave(0.25);
border-radius: 1px;
background: root.tint;
}
// bar 3: delay 0.1, base 40%
Rectangle {
width: 3px;
y: parent.height - self.height;
height: parent.height * 0.4 * root.wave(0.125);
border-radius: 1px;
background: root.tint;
}
// bar 4: delay 0.3, base 80%
Rectangle {
width: 3px;
y: parent.height - self.height;
height: parent.height * 0.8 * root.wave(0.375);
border-radius: 1px;
background: root.tint;
}
}
}
import { ImmersiveTrackInfo } from "ImmersiveTrackInfo.slint";
export component StaticPanel inherits Rectangle {
in property <length> viewport-width: 1280px;
in property <length> viewport-height: 720px;
// Base art box. Tauri uses `min(52vh, 460px)`, but the Slint group must also
// leave room for the metadata block + the floating player, or the quality
// badge gets clipped under the bar. Static has NO breathing growth, so the
// height budget divides by 1.0 (no /1.25) and the panel gap is 20px (not 40).
// Reserve = pad-top(52) + spacing(20) + info(160) + player-clearance(132) =
// 364px. Player clearance 132 is KEPT identical to AlbumReactivePanel (same
// floating ImmersivePlayerBar); if it changes, BOTH the 132 padding-bottom
// below and this 364 reserve must move together. Clamped to 180..460px;
// width cap 0.55 captures the Svelte narrow-window 55vw intent.
// Base art box. The group must leave room for the metadata block + the
// floating player, or the quality badge gets clipped under the bar. Static
// has NO breathing growth, so the height budget divides by 1.0 (no /1.25)
// and the panel gap is 20px (not 40). Reserve = pad-top(52) + spacing(20) +
// info(160) + player-clearance(132) = 364px. Player clearance 132 is KEPT
// identical to AlbumReactivePanel (same floating ImmersivePlayerBar); if it
// changes, BOTH the 132 padding-bottom below and this 364 reserve must move
// together.
//
// RESPONSIVE: previously capped at ~360-460px, which left a LARGE window
// mostly empty (the art stayed small in a huge frame). We let the art GROW
// with the window like AlbumReactivePanel: the `vh-364` height budget already
// scales, and we raise the hard cap 460 -> 640px and the width fraction
// 0.55 -> 0.62 so a big window is filled. The 180px floor keeps small windows
// safe (small was confirmed good).
property <length> base-art: Math.max(180px,
Math.min(Math.min(root.viewport-height - 364px, root.viewport-width * 0.55), 460px));
Math.min(Math.min(root.viewport-height - 364px, root.viewport-width * 0.62), 640px));
// Fixed size — no art-scale.
property <length> art-size: root.base-art;
@@ -146,73 +97,9 @@ export component StaticPanel inherits Rectangle {
}
}
// --- Track info ----------------------------------------------------
info-block := VerticalLayout {
alignment: center;
spacing: 6px;
// "Now Playing" indicator: equalizer bars + label. Shown only while
// playing (Svelte {#if isPlaying}).
if NowPlayingState.playing: HorizontalLayout {
alignment: center;
spacing: 8px;
padding-bottom: 8px;
VerticalLayout {
alignment: center;
EqualizerBars {
tint: #7c3aed;
}
}
Text {
text: @tr("Now Playing");
color: #7c3aed;
font-size: 12px;
font-weight: 600;
letter-spacing: 0.5px;
vertical-alignment: center;
}
}
// Track title. (Explicit badge OMITTED: NowPlayingState has no
// `explicit` field and the sibling AlbumReactivePanel omits it too.)
Text {
text: NowPlayingState.title;
color: #ffffff;
font-size: 28px;
font-weight: 700;
horizontal-alignment: center;
overflow: elide;
}
// Artist.
Text {
text: NowPlayingState.artist;
color: #ffffffb3;
font-size: 18px;
horizontal-alignment: center;
overflow: elide;
}
// Album (italic, dimmer). Shown only when present (Svelte {#if album}).
if NowPlayingState.album != "": Text {
text: NowPlayingState.album;
color: #ffffff80;
font-size: 14px;
font-italic: true;
horizontal-alignment: center;
overflow: elide;
}
// Quality badge (Svelte QualityBadgeStatic full mode). Self-hides
// when tier == "". Centered under the text.
HorizontalLayout {
alignment: center;
padding-top: 12px;
QualityBadgeFull {
tier: NowPlayingState.quality-tier;
detail: NowPlayingState.quality-detail;
}
}
// --- Track info (shared, homologated across all 3 panels) ----------
ImmersiveTrackInfo {
equalizer-tint: #7c3aed;
}
}
}