feat: flip the now-playing cover when the picture changes

The cover turns edge-on, swaps, and turns back with an overshooting
curve. Slint has no perspective, so the turn squashes the width.

Whether to flip is decided by a hash of the decoded pixels, not by the
cover id: Navidrome gives every track its own id even when the whole
album shares one image. While the new cover loads the old one stays up,
and the next track's cover is fetched ahead so a skip decides at once.
This commit is contained in:
Ansho Rei
2026-11-04 13:44:38 +01:00
parent 578a4f5607
commit 2e8b2e6a02
6 changed files with 179 additions and 14 deletions
+22 -1
View File
@@ -756,6 +756,9 @@ component NowPlayingView inherits Rectangle {
in property <string> duration;
in property <bool> paused;
in property <bool> has-track;
// True while the cover turns away; the app swaps the cover at edge-on and
// sets it back to false to turn the new one in.
in property <bool> flip-out;
in property <[Item]> queue;
in property <int> queue-count;
in property <int> queue-selected;
@@ -786,9 +789,11 @@ component NowPlayingView inherits Rectangle {
spacing: 10px * Theme.s;
width: root.art-size;
Art {
art := Art {
width: root.art-size;
height: root.art-size;
// Set here so the turned state below has a value to return to.
transform-scale-x: 100%;
source: root.cover;
has-image: root.has-cover;
tint: root.tint;
@@ -873,6 +878,20 @@ component NowPlayingView inherits Rectangle {
}
}
}
// A flip around the vertical axis, faked by squashing the width: Slint has
// no perspective. The turn back overshoots a little and settles.
states [
turned when root.flip-out: {
art.transform-scale-x: 0%;
in {
animate art.transform-scale-x { duration: 170ms; easing: ease-in; }
}
out {
animate art.transform-scale-x { duration: 380ms; easing: cubic-bezier(0.34, 1.5, 0.64, 1); }
}
}
]
}
export component AppWindow inherits Window {
@@ -936,6 +955,7 @@ export component AppWindow inherits Window {
in property <string> np-position;
in property <string> np-duration;
in property <bool> np-paused;
in property <bool> np-flip-out;
in property <[Item]> queue-items;
in property <int> queue-count;
in property <int> queue-selected;
@@ -1097,6 +1117,7 @@ export component AppWindow inherits Window {
duration: root.np-duration;
paused: root.np-paused;
has-track: root.np-has-track;
flip-out: root.np-flip-out;
queue: root.queue-items;
queue-count: root.queue-count;
queue-selected: root.queue-selected;