fix(immersive): persist volume on drag-end

The immersive VolumeBar only called set-volume (live) and never persist-volume, so a volume set in the immersive view was lost on restart/track-change. Adds a released(float) callback emitted on pointer-up, wired to NowPlayingState.persist-volume — parity with the NPB sliders. Pure .slint; persist-volume already exists in Rust.

cc
This commit is contained in:
vicrodh committed 2026-07-13 21:01:48 -06:00
1 parent 41f8578b78
commit ba7be747a7
1 file changed
+14 -1
+14 -1
View File
@@ -153,7 +153,8 @@ component TinyBar inherits Rectangle {
component VolumeBar inherits Rectangle {
in property <float> value: 0.0; // 0..1
in property <bool> locked: false;
callback changed(float); // emits 0..1
callback changed(float); // emits 0..1 — live (every drag tick)
callback released(float); // emits 0..1 — drag-end only (persist)
// The visual fill fraction: pinned to 100% when locked (matches Tauri).
property <float> shown: root.locked ? 1.0 : Math.max(0.0, Math.min(1.0, root.value));
@@ -226,6 +227,13 @@ component VolumeBar inherits Rectangle {
root.changed(Math.max(0.0, Math.min(1.0, self.mouse-x / self.width)));
}
}
// Persist only the final value on drag-end (matches the NPB sliders'
// released -> persist-volume; live changes still fire via changed).
pointer-event(e) => {
if (!root.locked && e.kind == PointerEventKind.up) {
root.released(Math.max(0.0, Math.min(1.0, self.mouse-x / self.width)));
}
}
}
}
@@ -354,6 +362,11 @@ component ImmersivePlayerBar inherits Rectangle {
NowPlayingState.set-volume(v);
}
}
released(v) => {
if (!root.vol-locked) {
NowPlayingState.persist-volume(v);
}
}
}
Rectangle {
x: root.width - 42px;