Files
qbz/crates/qbz-slint/ui/shell/SeekBar.slint
T
vicrodh 8fa03a8c03 feat(slint): NowPlayingBar Mode C "Small" + mode shell + floating album-art preview
- New mode shell ui/shell/NowPlayingBar.slint switches on ShellState.npb-mode
  (0/1 -> existing PlayerBar untouched except a mode-aware height, 2 -> new
  PlayerBarSmall). AppShell mounts it; npb_mode "small" persists in ui_prefs.
- PlayerBarSmall: one 42px row (the album art defines the height, no bump) — a
  3px full-width top seekbar (SeekBar gains a show-times prop) + a symmetric
  3-column controls row that mirrors PlayerBar's responsive side-frac so the
  transport is window-centred. Compact SongCard (art border + flush-left +
  text-center + smaller fonts), a tabular 2-row time column (monospace), an
  inline 2-row AudioStamp (no format icon), and the right cluster
  (ViewMode/Connect/Cast/Lyrics/Settings-flyout/Volume/Queue). Responsive
  volume: inline QbzSlider when wide, an upward QbzVerticalSlider flyout when
  narrow.
- New ui/primitives/QbzVerticalSlider.slint.
- Floating album-art hover preview (1:1 Tauri): NowPlayingState.artwork-large
  (300px, loaded via the same source-aware artwork funnel) + a global
  ArtPreviewState rendered by the new ArtPreviewOverlay (an overlay, NOT a
  PopupWindow, so it never steals hover -> no flicker). New/Classic/Small.
- Fix: settings.rs handle_bool now refreshes SettingsState on the non-cascade
  path so the bar's Normalization/Gapless toggles reflect their real state
  (shared path, also helps New/Classic). Protected audio backend untouched.
- Context icon turntable -> layers (Tauri parity, all now-playing modes).

cc
2026-06-12 13:18:54 -06:00

150 lines
5.5 KiB
Plaintext

// Player seek bar — elapsed time, a three-line track (total / cached /
// progress) with a hover thumb, and the remaining time. On hover the
// cursor shows a time bubble with a downward caret marking the position
// it would seek to.
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
export component SeekBar inherits HorizontalLayout {
in property <float> progress: 0.0; // 0..1 played
in property <float> cache: 0.0; // 0..1 buffered
in property <float> seekable-max: 1.0; // furthest seekable fraction (stream lock)
in property <string> elapsed: "0:00";
in property <string> remaining: "0:00";
in property <int> duration-secs: 0;
// Whether to render the leading/trailing time labels. Default true so the
// New/Classic bars are unchanged; the Small bar mounts the top full-width
// seekbar with show-times:false (it carries its own time column instead).
in property <bool> show-times: true;
callback seek(float); // 0..1
spacing: root.show-times ? 12px : 0px;
function clamp01(v: float) -> float {
return Math.min(Math.max(v, 0.0), 1.0);
}
function fmt(secs: int) -> string {
return "\{Math.floor(secs / 60)}:\{Math.mod(secs, 60) < 10 ? "0" : ""}\{Math.mod(secs, 60)}";
}
if root.show-times: VerticalLayout {
alignment: center;
Text {
text: root.elapsed;
width: 44px;
horizontal-alignment: right;
color: Theme.text-muted;
font-size: 11px;
}
}
VerticalLayout {
alignment: center;
horizontal-stretch: 1;
track := Rectangle {
height: 3px;
border-radius: 2px;
background: Theme.surface-elevated;
// Buffered / cache line.
Rectangle {
x: 0;
y: 0;
width: parent.width * root.clamp01(root.cache);
height: parent.height;
border-radius: 2px;
background: Theme.text-muted;
opacity: 0.35;
}
// Playback progress line.
Rectangle {
x: 0;
y: 0;
width: parent.width * root.clamp01(root.progress);
height: parent.height;
border-radius: 2px;
background: Theme.accent;
}
// Hover thumb.
Rectangle {
width: 12px;
height: 12px;
border-radius: 6px;
background: Theme.text-primary;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
x: parent.width * root.clamp01(root.progress) - self.width / 2;
opacity: ta.has-hover ? 1.0 : 0.0;
animate opacity { duration: 100ms; }
}
// Tall, easy-to-grab hit area over the thin line.
ta := TouchArea {
width: 100%;
height: 18px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
// No-drop cursor over the not-yet-downloaded region.
mouse-cursor: (root.clamp01(self.mouse-x / self.width) > root.seekable-max)
? MouseCursor.not-allowed
: MouseCursor.pointer;
clicked => {
// Lock the seek target to what has downloaded while streaming.
root.seek(Math.min(root.clamp01(self.mouse-x / self.width), root.seekable-max));
}
}
// Hover time tooltip with a downward caret.
tip := Rectangle {
property <int> at-secs:
Math.round(root.clamp01(ta.mouse-x / track.width) * root.duration-secs);
x: Math.min(Math.max(ta.mouse-x - self.width / 2, 0px),
track.width - self.width);
y: -self.height - 11px;
width: bubble.preferred-width;
height: 24px;
opacity: ta.has-hover ? 1.0 : 0.0;
animate opacity { duration: 80ms; }
bubble := Rectangle {
background: Theme.surface-elevated;
border-radius: 4px;
drop-shadow-blur: 10px;
drop-shadow-color: #00000099;
HorizontalLayout {
padding-left: 9px;
padding-right: 9px;
Text {
text: root.fmt(tip.at-secs);
color: Theme.text-primary;
font-size: 11px;
font-weight: Typography.medium;
vertical-alignment: center;
}
}
}
// Caret — a small downward triangle under the bubble.
Path {
width: 10px;
height: 6px;
fill: Theme.surface-elevated;
commands: "M 0 0 L 5 6 L 10 0 Z";
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: parent.height - 1px;
}
}
}
}
if root.show-times: VerticalLayout {
alignment: center;
Text {
text: root.remaining;
width: 44px;
horizontal-alignment: left;
color: Theme.text-muted;
font-size: 11px;
}
}
}