From 8fa03a8c036990eaedcbb7285f8da88f387906a7 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Fri, 12 Jun 2026 13:18:54 -0600 Subject: [PATCH] feat(slint): NowPlayingBar Mode C "Small" + mode shell + floating album-art preview MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- crates/qbz-slint/src/main.rs | 9 +- crates/qbz-slint/src/playback.rs | 35 + crates/qbz-slint/src/settings.rs | 27 + crates/qbz-slint/src/ui_prefs.rs | 7 +- .../ui/primitives/QbzVerticalSlider.slint | 80 ++ crates/qbz-slint/ui/shell/AppShell.slint | 29 +- .../ui/shell/ArtPreviewOverlay.slint | 46 + crates/qbz-slint/ui/shell/NowPlayingBar.slint | 70 ++ crates/qbz-slint/ui/shell/PlayerBar.slint | 9 +- .../qbz-slint/ui/shell/PlayerBarSmall.slint | 1106 +++++++++++++++++ crates/qbz-slint/ui/shell/SeekBar.slint | 10 +- crates/qbz-slint/ui/shell/SongCard.slint | 183 ++- crates/qbz-slint/ui/state.slint | 25 + 13 files changed, 1606 insertions(+), 30 deletions(-) create mode 100644 crates/qbz-slint/ui/primitives/QbzVerticalSlider.slint create mode 100644 crates/qbz-slint/ui/shell/ArtPreviewOverlay.slint create mode 100644 crates/qbz-slint/ui/shell/NowPlayingBar.slint create mode 100644 crates/qbz-slint/ui/shell/PlayerBarSmall.slint diff --git a/crates/qbz-slint/src/main.rs b/crates/qbz-slint/src/main.rs index b086bd8b1..fe5c66e54 100644 --- a/crates/qbz-slint/src/main.rs +++ b/crates/qbz-slint/src/main.rs @@ -4916,10 +4916,11 @@ fn main() -> Result<(), Box> { } } match (kind.as_str(), action.as_str()) { - // Now-playing bar layout switch (New / Classic). Persisted to - // ui_prefs so the choice survives restarts. Small/Large/window - // modes are disabled in the menu until those layouts land. - ("npb-view", mode @ ("new" | "classic")) => { + // Now-playing bar layout switch (New / Classic / Small). + // Persisted to ui_prefs so the choice survives restarts. + // Large/window modes are disabled in the menu until those + // layouts land. + ("npb-view", mode @ ("new" | "classic" | "small")) => { if let Some(w) = weak.upgrade() { w.global::() .set_npb_mode(crate::ui_prefs::npb_mode_index(mode)); diff --git a/crates/qbz-slint/src/playback.rs b/crates/qbz-slint/src/playback.rs index a0dbf60a3..2af8c5d5d 100644 --- a/crates/qbz-slint/src/playback.rs +++ b/crates/qbz-slint/src/playback.rs @@ -1171,6 +1171,32 @@ fn load_now_playing_artwork(weak: slint::Weak, art: qbz_models::Artwo }); } +/// Resolve a HIGHER-res now-playing cover (~300px) and apply it to +/// `NowPlayingState.artwork-large`. Feeds the hover preview that floats above +/// the bar's small art, so the ~220px popup is crisp instead of an upscale of +/// the 160px bar art. Mirrors [`load_now_playing_artwork`] but decodes larger +/// and writes the separate `artwork-large` slot. Source-aware via the SAME +/// `ArtworkRef` funnel (the caller passes a `Some(300)` ref). +fn load_now_playing_artwork_large(weak: slint::Weak, art: qbz_models::ArtworkRef) { + if art.is_empty() { + return; + } + let Some(cache) = crate::artwork::shared_cache() else { + return; + }; + tokio::spawn(async move { + let Some((pixels, w, h)) = + crate::artwork::fetch_and_decode_ref(&art, &cache, 300).await + else { + return; + }; + let _ = weak.upgrade_in_event_loop(move |win| { + let img = crate::artwork::pixels_to_image(&pixels, w, h); + win.global::().set_artwork_large(img); + }); + }); +} + /// Wall-clock now in milliseconds. Used by the poll loop to extrapolate the /// peer renderer's position (`position_ms + (now - updated_at_ms)`) while /// QBZ is CONTROLLING a peer (the local player is stopped, so the seek bar @@ -1280,6 +1306,10 @@ pub(crate) async fn refresh_now_playing_meta(runtime: &Runtime, weak: &slint::We // For non-Plex tracks both collapse to the same `artwork_ref()`. let artwork = track.artwork_ref_with_plex(&plex.base_url, &plex.token, None); let bar_artwork = track.artwork_ref_with_plex(&plex.base_url, &plex.token, Some(160)); + // Higher-res cover for the hover preview that floats above the bar art. Same + // source-aware funnel; a ~300px server-side transcode so the ~220px popup is + // crisp without paying for the full original. One extra fetch per track. + let preview_artwork = track.artwork_ref_with_plex(&plex.base_url, &plex.token, Some(300)); // Quality badge: tier from bit depth (24-bit+ = Hi-Res), exact detail line // reused from the shared formatter so it matches the track-row badges. let quality_tier = match track.bit_depth { @@ -1430,9 +1460,14 @@ pub(crate) async fn refresh_now_playing_meta(runtime: &Runtime, weak: &slint::We // Clear the previous cover so it does not linger while the new // one resolves. np.set_artwork(slint::Image::default()); + // Clear the hover-preview cover too, exactly like the bar art, so the + // floating preview never shows the previous track while the new high-res + // cover resolves. + np.set_artwork_large(slint::Image::default()); }); load_now_playing_artwork(weak.clone(), bar_artwork); + load_now_playing_artwork_large(weak.clone(), preview_artwork); } /// Record the playback CONTEXT — the source the queue was launched from — on diff --git a/crates/qbz-slint/src/settings.rs b/crates/qbz-slint/src/settings.rs index 9421d6fd0..0b274f98b 100644 --- a/crates/qbz-slint/src/settings.rs +++ b/crates/qbz-slint/src/settings.rs @@ -599,6 +599,15 @@ pub fn apply_snapshot(window: &AppWindow, snap: SettingsSnapshot) { st.set_stream_uncached(snap.stream_uncached); st.set_streaming_only(snap.streaming_only); st.set_normalization(snap.normalization); + // Mirror the four output LEDs onto NowPlayingState too, so the Mode C + // "Small" now-playing bar has a single source for the song card + the + // DAC/EXC cluster. Cloned because the SettingsState setters below consume + // the snapshot's String fields via `.into()`. + let np = window.global::(); + np.set_output_backend_label(snap.output_backend_label.clone().into()); + np.set_output_mode_label(snap.output_mode_label.clone().into()); + np.set_output_backend_active(snap.output_backend_active); + np.set_output_mode_active(snap.output_mode_active); st.set_output_backend_label(snap.output_backend_label.into()); st.set_output_mode_label(snap.output_mode_label.into()); st.set_output_backend_active(snap.output_backend_active); @@ -870,6 +879,24 @@ pub async fn handle_bool( // triggering toggle alone required. let apply = if cascaded { Apply::Reinit } else { apply }; apply_audio(&ctx, &runtime, apply); + // Reflect the persisted value back onto SettingsState so toggles + // that are purely driven by `checked: SettingsState.x` (e.g. the + // now-playing bar audio-menu QbzToggles for Normalization/Gapless) + // actually flip. The Settings panel's own toggles already reflect + // their click optimistically, but the bar flyout's do NOT self-flip + // — they need this push. Skipped when cascaded, since the full + // snapshot re-push below already carries the new value. + if !cascaded { + let key = key.to_string(); + let _ = weak.upgrade_in_event_loop(move |w| { + let st = w.global::(); + match key.as_str() { + "normalization" => st.set_normalization(value), + "gapless" => st.set_gapless(value), + _ => {} + } + }); + } } Err(e) => log::error!("[qbz-slint] failed to persist '{key}': {e}"), } diff --git a/crates/qbz-slint/src/ui_prefs.rs b/crates/qbz-slint/src/ui_prefs.rs index f1804b1bd..e6504d103 100644 --- a/crates/qbz-slint/src/ui_prefs.rs +++ b/crates/qbz-slint/src/ui_prefs.rs @@ -44,8 +44,8 @@ pub struct UiPrefs { /// Streaming-quality key — one of `STREAMING_QUALITIES[*].key`. #[serde(default = "default_streaming_quality")] pub streaming_quality: String, - /// Now-playing bar layout: `"new"` | `"classic"`. Maps to - /// `ShellState.npb-mode` (0 / 1). + /// Now-playing bar layout: `"new"` | `"classic"` | `"small"`. Maps to + /// `ShellState.npb-mode` (0 / 1 / 2). #[serde(default = "default_npb_mode")] pub npb_mode: String, } @@ -68,10 +68,11 @@ impl Default for UiPrefs { } /// Map a persisted npb-mode key to the `ShellState.npb-mode` int -/// (New = 0, Classic = 1). Unknown keys fall back to New. +/// (New = 0, Classic = 1, Small = 2). Unknown keys fall back to New. pub fn npb_mode_index(key: &str) -> i32 { match key { "classic" => 1, + "small" => 2, _ => 0, } } diff --git a/crates/qbz-slint/ui/primitives/QbzVerticalSlider.slint b/crates/qbz-slint/ui/primitives/QbzVerticalSlider.slint new file mode 100644 index 000000000..bc77cc5b0 --- /dev/null +++ b/crates/qbz-slint/ui/primitives/QbzVerticalSlider.slint @@ -0,0 +1,80 @@ +// Vertical integer slider primitive — dark-themed, draggable. The Y-axis +// mirror of QbzSlider, inverted so the TOP of the track is `maximum` and the +// BOTTOM is `minimum` (the natural orientation for a volume column popping up +// over a button). Like the other primitives it does not own its value: it +// emits `changed(new-value)` and the caller updates the bound state. + +import { Theme } from "../foundation/semantic-colors.slint"; + +export component QbzVerticalSlider inherits Rectangle { + in property minimum: 0; + in property maximum: 100; + in property value: 0; + callback changed(int); + + width: 22px; + height: 120px; + + // Fraction of the track the current value sits at, clamped to [0, 1]. + property fraction: root.maximum > root.minimum + ? max(0.0, min(1.0, (root.value - root.minimum) / (root.maximum - root.minimum))) + : 0.0; + property thumb-size: 16px; + // Travel range for the thumb centre (top..bottom of the column). + property travel: root.height - root.thumb-size; + + // Track (the full vertical rail). + Rectangle { + x: Math.round((parent.width - self.width) / 2 / 1px) * 1px; + width: 4px; + border-radius: 2px; + background: Theme.surface-elevated; + } + + // Accent fill — grows UP from the bottom (inverted: more value = taller). + Rectangle { + x: Math.round((parent.width - self.width) / 2 / 1px) * 1px; + width: 4px; + height: root.thumb-size / 2 + root.fraction * root.travel; + // Pin to the bottom so the fill rises from the floor. + y: root.height - self.height; + border-radius: 2px; + background: Theme.accent; + } + + // Thumb. fraction 1.0 (max) → top (y == 0); fraction 0.0 (min) → bottom. + Rectangle { + x: Math.round((parent.width - self.width) / 2 / 1px) * 1px; + y: (1.0 - root.fraction) * root.travel; + width: root.thumb-size; + height: root.thumb-size; + border-radius: root.thumb-size / 2; + background: Theme.text-primary; + } + + // Map a pointer y to a clamped, rounded integer value (inverted axis). + function value-from-y(py: length) -> int { + root.minimum + round( + max(0.0, min(1.0, 1.0 - (py - root.thumb-size / 2) / max(1px, root.travel))) + * (root.maximum - root.minimum) + ) + } + + ta := TouchArea { + mouse-cursor: pointer; + + // Jump to the click point on press-down. + pointer-event(e) => { + if (e.kind == PointerEventKind.down + && root.value-from-y(self.mouse-y) != root.value) { + root.changed(root.value-from-y(self.mouse-y)); + } + } + // Continuous drag while held. + moved => { + if (root.value-from-y(self.mouse-y) != root.value) { + root.changed(root.value-from-y(self.mouse-y)); + } + } + } +} diff --git a/crates/qbz-slint/ui/shell/AppShell.slint b/crates/qbz-slint/ui/shell/AppShell.slint index 0b00ee11c..d489cdb59 100644 --- a/crates/qbz-slint/ui/shell/AppShell.slint +++ b/crates/qbz-slint/ui/shell/AppShell.slint @@ -13,6 +13,7 @@ import { Sidebar } from "Sidebar.slint"; import { HeaderBar } from "HeaderBar.slint"; import { HeaderMenuOverlay } from "HeaderMenuOverlay.slint"; import { TooltipOverlay } from "TooltipOverlay.slint"; +import { ArtPreviewOverlay } from "ArtPreviewOverlay.slint"; import { SidebarFolderPopup } from "SidebarFolderPopup.slint"; import { SidebarTooltip } from "SidebarTooltip.slint"; import { SidebarPlaylistsPopup } from "SidebarPlaylistsPopup.slint"; @@ -33,7 +34,7 @@ import { PlaylistImportModal } from "../primitives/PlaylistImportModal.slint"; import { QconnectDevModal } from "QconnectDevModal.slint"; import { DragGhost } from "../primitives/DragGhost.slint"; import { Toast } from "../primitives/Toast.slint"; -import { PlayerBar } from "PlayerBar.slint"; +import { NowPlayingBar } from "NowPlayingBar.slint"; import { QueueSidebar } from "QueueSidebar.slint"; import { LyricsSidebar } from "LyricsSidebar.slint"; import { HomeView } from "../discover/HomeView.slint"; @@ -174,11 +175,16 @@ export component AppShell inherits Rectangle { // shell). `root.height` is the AppShell height (pinned to // the window in app.slint). // - // NOTE: `Layout.player-bar-height` is the single source of - // truth for the bar height (New + Classic both use it). - // When the Small / Large bar layouts land with a DIFFERENT - // height, make that value mode-aware and this stays correct. - height: root.height - Layout.header-height - Layout.player-bar-height - 8px; + // NOTE: the bar height is mode-aware. New + Classic use the + // full `Layout.player-bar-height` (112px); Small (npb-mode 2) + // collapses the bar to one header-tall row (42px), so the + // content area gains ~70px. Computed inline (mirrors the same + // expression in PlayerBar.slint `height:`) to keep `Layout` + // a pure leaf independent of ShellState. Large (mode 3) will + // add its own branch here when it lands. + height: root.height - Layout.header-height + - (ShellState.npb-mode == 2 ? Layout.header-height : Layout.player-bar-height) + - 8px; vertical-stretch: 1; background: Theme.surface-main; border-radius: Radius.md; @@ -395,7 +401,9 @@ export component AppShell inherits Rectangle { } } - PlayerBar { + // Mode-aware bottom bar shell: New/Classic -> PlayerBar, Small -> + // PlayerBarSmall. Forwards the same bindings the bar always took. + NowPlayingBar { open-album(id) => { root.open-album(id); } @@ -495,4 +503,11 @@ export component AppShell inherits Rectangle { width: 100%; height: 100%; } + + // Floating album-art hover preview — overlay-rendered (not a PopupWindow) so + // it never steals hover from the trigger. On top of everything. + ArtPreviewOverlay { + width: 100%; + height: 100%; + } } diff --git a/crates/qbz-slint/ui/shell/ArtPreviewOverlay.slint b/crates/qbz-slint/ui/shell/ArtPreviewOverlay.slint new file mode 100644 index 000000000..459445488 --- /dev/null +++ b/crates/qbz-slint/ui/shell/ArtPreviewOverlay.slint @@ -0,0 +1,46 @@ +// Global floating album-art preview — a 220x220 high-res cover that floats +// ABOVE the now-playing bar's small cover while the pointer hovers it (1:1 with +// Tauri). Mounted LAST in AppShell (on top of everything), fills the window and +// is NON-INTERACTIVE (no TouchArea → clicks pass through and, crucially, it +// never steals hover from the trigger — a PopupWindow did, causing flicker). +// Driven by ArtPreviewState (anchor + visibility); reads the cover straight +// from NowPlayingState. + +import { Theme } from "../foundation/semantic-colors.slint"; +import { ArtPreviewState, NowPlayingState } from "../state.slint"; + +export component ArtPreviewOverlay inherits Rectangle { + // root fills the window; transparent + non-interactive. + visible: ArtPreviewState.show && NowPlayingState.has-track; + + property card: 232px; + + Rectangle { + width: root.card; + height: root.card; + // Centred on the art (clamped 8px inside the window), floating just + // above it (bottom ~8px above the art's top edge). + x: Math.clamp(ArtPreviewState.anchor-x - self.width / 2, + 8px, + Math.max(8px, root.width - self.width - 8px)); + y: ArtPreviewState.anchor-y - self.height - 8px; + border-radius: 8px; + background: Theme.surface-card; + border-width: 1px; + border-color: Theme.border-subtle; + drop-shadow-blur: 16px; + drop-shadow-color: #00000088; + clip: true; + + Image { + width: 220px; + height: 220px; + x: 6px; + y: 6px; + image-fit: contain; + source: NowPlayingState.artwork-large.width > 0 + ? NowPlayingState.artwork-large + : NowPlayingState.artwork; + } + } +} diff --git a/crates/qbz-slint/ui/shell/NowPlayingBar.slint b/crates/qbz-slint/ui/shell/NowPlayingBar.slint new file mode 100644 index 000000000..77ccbe147 --- /dev/null +++ b/crates/qbz-slint/ui/shell/NowPlayingBar.slint @@ -0,0 +1,70 @@ +// Now-playing bar SHELL — switches the bottom bar body on ShellState.npb-mode. +// +// This thin wrapper is the real "mode seam": it mounts the EXISTING PlayerBar +// (which itself handles New = 0 and Classic = 1 internally) for modes 0/1, and +// the new PlayerBarSmall (Mode C) for mode 2. Large (mode 3) will add a third +// branch later; until then it falls through to PlayerBar (Default). +// +// AppShell mounts THIS instead of PlayerBar directly, forwarding the same +// bindings; this component forwards them identically to whichever body is live. + +import { Layout } from "../foundation/layout.slint"; +import { ShellState } from "../state.slint"; +import { PlayerBar } from "PlayerBar.slint"; +import { PlayerBarSmall } from "PlayerBarSmall.slint"; + +export component NowPlayingBar inherits Rectangle { + callback open-album(string); + callback open-artist(string); + callback media-action(string, string, string); + callback settings-bool(string, bool); + + // EXPLICIT mode-aware height on the wrapper itself. The bottom bar lives in + // AppShell's outer VerticalLayout slot, which sizes a plain Rectangle child + // to its CONTENT height — and a Rectangle does NOT auto-adopt a conditional + // child's explicit height, so without this the row could collapse (the + // layout-collapse footgun). Pinning the height here (mirrors the body's own + // `height:`) makes the slot deterministic; the live body fills 100%. + // Small (mode 2): a thin full-width top seekbar (3px) that doubles as the + // divider between the content area and the bar, plus the controls row that + // fills the rest — the whole bar is header-height tall (the large album art + // defines the visual height, no extra band bump). + height: ShellState.npb-mode == 2 ? Layout.header-height : Layout.player-bar-height; + + // Mode 2 (Small): the compact one-row bar. + if ShellState.npb-mode == 2: PlayerBarSmall { + width: 100%; + height: 100%; + open-album(id) => { + root.open-album(id); + } + open-artist(id) => { + root.open-artist(id); + } + media-action(kind, id, action) => { + root.media-action(kind, id, action); + } + settings-bool(k, v) => { + root.settings-bool(k, v); + } + } + + // Modes 0/1 (New / Classic) — and any other mode as a safe fallback — + // keep the existing full PlayerBar untouched. + if ShellState.npb-mode != 2: PlayerBar { + width: 100%; + height: 100%; + open-album(id) => { + root.open-album(id); + } + open-artist(id) => { + root.open-artist(id); + } + media-action(kind, id, action) => { + root.media-action(kind, id, action); + } + settings-bool(k, v) => { + root.settings-bool(k, v); + } + } +} diff --git a/crates/qbz-slint/ui/shell/PlayerBar.slint b/crates/qbz-slint/ui/shell/PlayerBar.slint index 393854351..ab422c332 100644 --- a/crates/qbz-slint/ui/shell/PlayerBar.slint +++ b/crates/qbz-slint/ui/shell/PlayerBar.slint @@ -119,7 +119,12 @@ export component PlayerBar inherits Rectangle { callback media-action(string, string, string); callback settings-bool(string, bool); - height: Layout.player-bar-height; + // Mode-aware bar height: Small (npb-mode 2) collapses to one header-tall + // row (42px); New/Classic keep the full 112px. Computed inline (not on the + // Layout global) so `Layout` stays a pure leaf with no dependency on the + // stateful ShellState — avoiding an import direction that would couple + // foundation to state. + height: ShellState.npb-mode == 2 ? Layout.header-height : Layout.player-bar-height; background: Theme.surface-card; // Responsive column zones. The song-card (left) and the buttons (right) @@ -717,7 +722,7 @@ export component PlayerBar inherits Rectangle { ContextMenuItem { icon: @image-url("../assets/icons/rows-3.svg"); label: @tr("Small"); - enabled: false; + selected: ShellState.npb-mode == 2; clicked => { root.media-action("npb-view", "", "small"); } diff --git a/crates/qbz-slint/ui/shell/PlayerBarSmall.slint b/crates/qbz-slint/ui/shell/PlayerBarSmall.slint new file mode 100644 index 000000000..fc5a9ab59 --- /dev/null +++ b/crates/qbz-slint/ui/shell/PlayerBarSmall.slint @@ -0,0 +1,1106 @@ +// Bottom now-playing / transport bar — Mode C "Small" (redesigned). +// +// One bar, header-height tall (42px). A THIN top seekbar strip (3px) sits over +// the controls row which fills the rest (~39px) — NO band bump. The large +// album art (37px, flush to the left edge with a 2px border) is the dominant +// element that defines the visual height. +// +// ┌──────────────────────────────────────────────────────────────────┐ +// │ ▰▰▰▰▰▰▰▰▰▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱ ← top seekbar │ (3px, full width) +// ├──────────────────────────────────────────────────────────────────┤ +// │[art] title 00:02 (i)⏮ ⏪ ▶ ⏩ ⏭ + STAMP view cast lyr ⚙ vol q │ (~39px) +// │ artist 04:32 │ +// └──────────────────────────────────────────────────────────────────┘ +// +// A. TOP seekbar — full-width (no side padding), 3-color (bg + cache + +// progress), NO time labels (show-times:false). It is the visual border +// between the content area and the bar. +// +// B. CONTROLS ROW — a SYMMETRIC 3-column layout that mirrors PlayerBar's +// New/Classic mechanism (PlayerBar.slint:138-179): the LEFT and RIGHT +// columns share ONE responsive `side-frac` of the row width, so the CENTER +// transport column is window-centred and PLAY lands on the window centre +// (aligned with the header search) at every width. +// LEFT — album art (42px, 3px left inset) · 2-line title/artist (smaller +// font) · a fixed 2-row time column (elapsed / duration). +// CENTER — the transport cluster (info · shuffle · prev · PLAY · next · +// repeat · +), reused, symmetric, centred. +// RIGHT — the right control SET, right-aligned, the AudioStamp now PART +// of it: AudioStamp · ViewMode · Connect · Cast · Lyrics · +// Settings · Volume · Queue. +// +// Mounted by NowPlayingBar.slint when ShellState.npb-mode == 2. Reads +// NowPlayingState directly; bubbles album/artist/media actions up to the shell. + +import { Theme } from "../foundation/semantic-colors.slint"; +import { Layout } from "../foundation/layout.slint"; +import { Radius } from "../foundation/radius.slint"; +import { QbzIcon } from "../primitives/QbzIcon.slint"; +import { QbzSlider } from "../primitives/QbzSlider.slint"; +import { QbzVerticalSlider } from "../primitives/QbzVerticalSlider.slint"; +import { QbzToggle } from "../primitives/QbzToggle.slint"; +import { IconButton } from "../primitives/BarControls.slint"; +import { ContextMenu } from "../primitives/ContextMenu.slint"; +import { ContextMenuItem } from "../primitives/ContextMenuItem.slint"; +import { SeekBar } from "SeekBar.slint"; +import { SongCard } from "SongCard.slint"; +import { TransportControls } from "TransportControls.slint"; +import { NowPlayingState, ShellState, SettingsState, QconnectDevState } from "../state.slint"; + +// Qobuz Connect button — monitor-speaker glyph; golden over a soft golden tint +// when a Qobuz Connect session owns playback. A local copy of PlayerBar's +// ConnectButton (it is a file-private component there, so it can't be imported) +// — kept byte-for-byte equivalent so Small and New look identical. +component ConnectButton inherits Rectangle { + in property active: false; + callback clicked(); + + property gold: #e0b341; + + width: 32px; + height: 32px; + border-radius: Radius.sm; + background: root.active + ? root.gold.with-alpha(0.16) + : (ta.has-hover ? Theme.surface-hover : transparent); + border-width: root.active ? 1px : 0px; + border-color: root.gold.with-alpha(0.45); + + QbzIcon { + source: @image-url("../assets/icons/monitor-speaker.svg"); + width: 16px; + height: 16px; + x: Math.round((parent.width - self.width) / 2 / 1px) * 1px; + y: Math.round((parent.height - self.height) / 2 / 1px) * 1px; + tint: root.active + ? root.gold + : (ta.has-hover ? Theme.text-primary : Theme.text-secondary); + } + + ta := TouchArea { + mouse-cursor: pointer; + clicked => { + root.clicked(); + } + } +} + +// Inline 2-row AudioStamp (owner redesign — NO format icon): +// +// Row 1 (focus): [TIER] [detail] e.g. HI-RES 24-bit / 96 kHz +// Row 2 (secondary): [BACKEND] [MODE] the two LEDs, smaller, below. +// +// The quality line is the BRIGHTER one (detail = text-primary, tier = +// text-secondary, ~9px) so the LEDs (~6px, below) don't steal the focus. The +// tier label is built MANUALLY from NowPlayingState.quality-tier (no +// QualityBadgeFull — that one carries the icon + stacks tier/detail vertically). +// +// No pills (ADR-008): backend LED blue when active, mode LED green when active, +// muted grey otherwise. Right-aligned + width-clamped (via the parent's +// max-width) so it never blows out the control row. The cast/remote variants +// are kept, re-fit under the new 2-row structure. +component AudioStamp inherits VerticalLayout { + spacing: 1px; + alignment: center; + horizontal-stretch: 0; + + // Manual tier label: hires→HI-RES, mp3→MP3, lossless→LOSSLESS, else→CD. + property tier-label: NowPlayingState.quality-tier == "hires" + ? "HI-RES" + : (NowPlayingState.quality-tier == "mp3" + ? "MP3" + : (NowPlayingState.quality-tier == "lossless" ? "LOSSLESS" : "CD")); + + // === Row 1 — quality, INLINE + BRIGHT (the focus) ==================== + HorizontalLayout { + spacing: 5px; + alignment: end; + Text { + text: root.tier-label; + font-size: 9px; + font-weight: 700; + color: Theme.text-secondary; + vertical-alignment: center; + letter-spacing: 0.3px; + } + Text { + text: NowPlayingState.quality-detail; + font-size: 9px; + font-weight: 600; + color: Theme.text-primary; + vertical-alignment: center; + overflow: elide; + } + } + + // === Row 2 — the LEDs (secondary), BELOW the quality line ============ + // Local output → backend + mode labels side-by-side, ~6px, muted unless + // active. Hidden while remote/cast (those variants take the slot instead). + if !NowPlayingState.is-remote && !NowPlayingState.cast-active: HorizontalLayout { + spacing: 5px; + alignment: end; + Text { + text: NowPlayingState.output-backend-label; + font-size: 7px; + font-weight: 700; + color: NowPlayingState.output-backend-active + ? #5b8def + : Theme.text-muted; + vertical-alignment: center; + overflow: elide; + } + Text { + text: NowPlayingState.output-mode-label; + font-size: 7px; + font-weight: 700; + color: NowPlayingState.output-mode-active + ? #3fae6a + : Theme.text-muted; + vertical-alignment: center; + overflow: elide; + } + } + + // Local-network cast (Chromecast / DLNA) → a single purple protocol LED, + // re-fit on row 2 under the quality line. + if NowPlayingState.cast-active && !NowPlayingState.is-remote: HorizontalLayout { + alignment: end; + Text { + text: NowPlayingState.cast-protocol == "dlna" ? "DLNA" : "CAST"; + font-size: 7px; + font-weight: 700; + color: #a855f7; + vertical-alignment: center; + } + } + + // QConnect renderer-name caption — shown only when a PEER renderer owns + // playback AND a name is known (existing cast-target field; no new state). + // Sits on row 2 under the quality line. + if NowPlayingState.is-remote && NowPlayingState.cast-target != "": HorizontalLayout { + spacing: 3px; + alignment: end; + VerticalLayout { + alignment: center; + QbzIcon { + source: @image-url("../assets/icons/monitor-speaker.svg"); + width: 10px; + height: 10px; + tint: #e0b341; + } + } + Text { + text: NowPlayingState.cast-target; + font-size: 8px; + font-weight: 600; + color: #e0b341; + vertical-alignment: center; + overflow: elide; + // Generous cap — there is empty space to the LEFT of the right-aligned + // stamp, so the renderer name should use it instead of truncating at + // 72px. The right zone clips, so a very long name still can't reach the + // centre transport; `elide` handles the extreme case. + max-width: 220px; + } + } +} + +// Thin vertical separator reused inside the controls row (left zone: song-card +// vs time column; right zone: AudioStamp vs the icon cluster). A 1px line, +// border-subtle, ~60% of the row height, vertically centred. The horizontal +// spacing on each side is the caller's responsibility (gap property) so #6 can +// breathe more than #5. +component Sep inherits HorizontalLayout { + in property gap: 6px; + // Per-side overrides (default to `gap`) so a separator can sit a bit closer + // to one neighbour than the other. + in property gap-left: root.gap; + in property gap-right: root.gap; + // A NESTED layout defaults to horizontal-stretch:1 (greedy) in Slint — + // without this the Sep ATE the row's spare width, centring its 1px line in + // a huge box ("un chingo de espacio") and starving the song card so its + // text elided early with lots of empty space to the right. Pin it to 0 so + // the Sep is exactly `gap-left + 1px + gap-right` and the card keeps the rest. + horizontal-stretch: 0; + alignment: center; + padding-left: root.gap-left; + padding-right: root.gap-right; + VerticalLayout { + alignment: center; + Rectangle { + width: 1px; + // ~60% of the ~39px controls row. + height: 24px; + background: Theme.border-subtle; + } + } +} + +export component PlayerBarSmall inherits Rectangle { + callback open-album(string); + callback open-artist(string); + callback media-action(string, string, string); + callback settings-bool(string, bool); + + // One bar, header-height tall: a 3px top seekbar strip + the controls row + // that fills the rest (no band bump — the large album art defines the height). + height: Layout.header-height; + background: Theme.surface-card; + + // Responsive side fraction — IDENTICAL to PlayerBar's New mechanism + // (PlayerBar.slint:138-140). LEFT and RIGHT columns share this fraction so + // they are symmetric, which puts the CENTER transport column dead-centre + // and lands PLAY on the window centre (aligned with the header search). + // width < 1366 -> 39% | 22% | 39% + // 1366..<1920 -> 30% | 40% | 30% + // width >= 1920 -> 25% | 50% | 25% + property side-frac: root.width >= 1920px + ? 0.25 + : (root.width >= 1366px ? 0.30 : 0.39); + property col-centre: 1.0 - 2.0 * root.side-frac; + + // WIDE = inline horizontal volume slider; NARROW = a button opening a + // vertical slider flyout. Same 1366px breakpoint family as the side-frac. + property volume-wide: root.width >= 1366px; + + // Volume lock, mirroring PlayerBar's vol-locked: the local ALSA-Direct + // (bit-perfect) lock is LIFTED while controlling a peer, plus the + // sink-pushed remote lock. When locked, the volume control dims + no-ops. + property vol-locked: (SettingsState.backend-is-alsa && SettingsState.alsa-plugin-is-hw && !NowPlayingState.is-remote) + || NowPlayingState.volume-locked; + + VerticalLayout { + spacing: 0px; + + // === A. TOP full-width seekbar (the content/bar divider) =========== + // No side padding so it spans edge-to-edge; show-times:false hides the + // labels (the controls row carries its own time column). Centred in the + // thin 3px strip; same NowPlayingState seek wiring as New. + Rectangle { + height: 3px; + clip: false; + VerticalLayout { + // Pull the seekbar ~2px UP so the progress line hugs the very + // top edge of the bar (the content/NPB divider) instead of + // sitting centred with slack above it. + y: -2px; + alignment: center; + SeekBar { + show-times: false; + progress: NowPlayingState.progress; + cache: NowPlayingState.cache; + seekable-max: NowPlayingState.seekable-max; + elapsed: NowPlayingState.elapsed; + remaining: NowPlayingState.remaining; + duration-secs: NowPlayingState.duration-secs; + seek(fraction) => { + NowPlayingState.seek(fraction); + } + } + } + } + + // === B. CONTROLS ROW — symmetric 3 columns (39/22/39 …) ============ + // Fills the bar height left over after the 3px seekbar (~39px) via + // vertical-stretch instead of an explicit height, so the total is exactly + // header-height with no bump. + HorizontalLayout { + vertical-stretch: 1; + padding-left: 0px; + padding-right: 6px; + spacing: 0px; + + // ---- LEFT column: art + title/artist + time column ------------ + Rectangle { + width: (parent.width - 6px) * root.side-frac; + clip: true; + HorizontalLayout { + // Zeroed so the Sep owns its full symmetric gap (the layout + // spacing was DOUBLING the separator gap — adding to the Sep's + // own padding). The Sep#5 now owns the full 10px reference gap + // on each side; the song card stretches to fill the rest. + spacing: 0px; + // No left inset: the album art is FLUSH to the window's left + // edge; its 2px border provides the visual edge instead of a + // margin. + padding-left: 0px; + + // Art (37px, fits the ~39px controls row + leaves a hair of + // breathing room) + 2-line title/artist via SongCard. The art + // gets a 2px subtle border (defines it while flush-left). + // show-badges false (the AudioStamp lives in the RIGHT set + // now); the smaller title via the new title-font-size prop. + // The controls row sizes the card (a HorizontalLayout + // vertically stretches its children), so no explicit + // height/y is needed. + SongCard { + horizontal-stretch: 1; + art-size: 37px; + art-border-width: 3px; + art-border-color: Theme.surface-card; + show-badges: false; + title-font-size: 13px; + // Tighten the art -> text gap by 2px (11 -> 9) for Small. + art-text-gap: 9px; + text-center: true; + open-album(id) => { + root.open-album(id); + } + open-artist(id) => { + root.open-artist(id); + } + open-context(kind, id) => { + root.media-action(kind, id, "open"); + } + track-info() => { + if (!NowPlayingState.is-ephemeral) { + root.media-action("track", NowPlayingState.track-id, "track-info"); + } + } + } + + // Separator: song-card (art+text) | time column. 8px toward + // the song card, +2px (10px) toward the timer (owner ask). + if NowPlayingState.has-track: Sep { + gap: 8px; + gap-right: 10px; + } + + // Time column — a fixed-width 2-row block (elapsed / total), + // where the quality badge used to sit. Uses EXISTING state + // only: NowPlayingState.elapsed (already MM:SS) for row 1 and + // duration-secs formatted MM:SS for row 2. + if NowPlayingState.has-track: VerticalLayout { + alignment: center; + spacing: 1px; + width: 40px; + Text { + text: NowPlayingState.elapsed; + // Monospace so each digit + the colon hold the SAME + // position as values change (tabular, alarm-clock + // style — the proportional UI font shifted the colon). + font-family: "monospace"; + font-size: 10px; + color: Theme.text-muted; + horizontal-alignment: left; + } + Text { + // MM:SS from duration-secs (same arithmetic as SeekBar.fmt). + text: "\{Math.floor(NowPlayingState.duration-secs / 60)}:\{Math.mod(NowPlayingState.duration-secs, 60) < 10 ? "0" : ""}\{Math.mod(NowPlayingState.duration-secs, 60)}"; + // Monospace for stable digit/colon positions (see above). + font-family: "monospace"; + font-size: 10px; + color: Theme.text-muted; + horizontal-alignment: left; + } + } + } + } + + // ---- CENTER column: transport, window-centred ----------------- + Rectangle { + width: (parent.width - 6px) * root.col-centre; + clip: true; + VerticalLayout { + alignment: center; + HorizontalLayout { + alignment: center; + TransportControls { + play-circle: false; + media-action(k, i, a) => { + root.media-action(k, i, a); + } + } + } + } + } + + // ---- RIGHT column: the control SET, right-aligned -------------- + // Order: AudioStamp · ViewMode · Connect · Cast · Lyrics · + // Settings · Volume · Queue. + Rectangle { + width: (parent.width - 6px) * root.side-frac; + clip: true; + HorizontalLayout { + alignment: end; + spacing: 1px; + + // AudioStamp — first in the set, clamped width. + if NowPlayingState.has-track: VerticalLayout { + alignment: center; + AudioStamp { + // Wider when a QConnect renderer name is shown (it + // grows leftward into the empty space before the + // centre transport; the right zone's clip is the real + // guard). Normal stamp stays compact at 150px. + max-width: (NowPlayingState.is-remote && NowPlayingState.cast-target != "") ? 280px : 150px; + } + } + + // Separator: AudioStamp | right-cluster icon buttons. This is + // the REFERENCE gap: 9px Sep padding + 1px parent layout + // spacing = 10px rendered on each side (symmetric). The parent + // keeps spacing:1px because the icon cluster needs it; the Sep + // padding is symmetric, so both sides render the same 10px. + if NowPlayingState.has-track: Sep { + gap: 8px; + // +2px toward the quality badge (owner ask); 8px toward + // the buttons (the right cluster's 1px spacing applies on + // each boundary on top of these). + gap-left: 10px; + } + + // ViewMode — the layout-menu flyout (how you exit Small). + VerticalLayout { + alignment: center; + Rectangle { + width: 32px; + height: 32px; + IconButton { + icon: @image-url("../assets/icons/layout-grid.svg"); + icon-size: 16px; + btn-width: 32px; + tooltip: @tr("Now Playing view"); + clicked => { + layout-menu.show(); + } + } + layout-menu := PopupWindow { + // Anchored just above the button at its natural + // content height. The inner ContextMenu is + // CONTENT-sized (6 rows × 33px + a 7px divider + + // the ContextMenu's 5px+5px vertical padding = + // 215px), so the popup height MUST match that + // content height — otherwise the rows top-align + // and leave empty slack at the bottom, floating + // the visible menu high above the bar. With + // height == content, `y + height` is the true + // visible bottom, homologated to the other + // flyouts at -7 (bottom flush just above the 3px + // seekbar; bar top edge sits at ≈ -6.5). + x: 32px - 196px; + y: -222px; + width: 196px; + height: 215px; + close-policy: close-on-click; + ContextMenu { + ContextMenuItem { + icon: @image-url("../assets/icons/panel-left.svg"); + label: @tr("New"); + selected: ShellState.npb-mode == 0; + clicked => { + root.media-action("npb-view", "", "new"); + } + } + ContextMenuItem { + icon: @image-url("../assets/icons/panel-right-close.svg"); + label: @tr("Classic"); + selected: ShellState.npb-mode == 1; + clicked => { + root.media-action("npb-view", "", "classic"); + } + } + ContextMenuItem { + icon: @image-url("../assets/icons/rows-3.svg"); + label: @tr("Small"); + selected: ShellState.npb-mode == 2; + clicked => { + root.media-action("npb-view", "", "small"); + } + } + ContextMenuItem { + icon: @image-url("../assets/icons/layout-grid.svg"); + label: @tr("Large"); + enabled: false; + clicked => { + root.media-action("npb-view", "", "large"); + } + } + Rectangle { + height: 7px; + Rectangle { + height: 1px; + y: 3px; + background: Theme.border-subtle; + } + } + ContextMenuItem { + icon: @image-url("../assets/icons/picture-in-picture-2.svg"); + label: @tr("Miniplayer"); + enabled: false; + clicked => { + root.media-action("npb-view", "", "miniplayer"); + } + } + ContextMenuItem { + icon: @image-url("../assets/icons/maximize-2.svg"); + label: @tr("Immersive"); + enabled: false; + clicked => { + root.media-action("npb-view", "", "immersive"); + } + } + } + } + } + } + + // Connect — golden when a session is on; opens the connect + // flyout (self-contained upward PopupWindow, verbatim from + // PlayerBar so Small drives the same device picker path). + VerticalLayout { + alignment: center; + Rectangle { + width: 32px; + height: 32px; + ConnectButton { + active: NowPlayingState.qconnect-connected; + clicked => { + qconnect-menu.show(); + } + } + qconnect-menu := PopupWindow { + // Inner Rectangle FILLS the popup, so the visible + // bottom == y + height. Homologated to -7 (flush + // just above the 3px seekbar; bar top ≈ -6.5). + x: 32px - 280px; + y: -251px; + width: 280px; + height: 244px; + close-policy: close-on-click-outside; + Rectangle { + background: Theme.surface-main; + border-radius: Radius.sm; + border-width: 1px; + border-color: Theme.border-muted; + drop-shadow-blur: 22px; + drop-shadow-color: Theme.card-shadow; + drop-shadow-offset-y: 6px; + VerticalLayout { + padding: 14px; + spacing: 12px; + HorizontalLayout { + spacing: 8px; + QbzIcon { + source: @image-url("../assets/icons/monitor-speaker.svg"); + width: 16px; + height: 16px; + tint: Theme.text-primary; + } + Text { + text: @tr("Qobuz Connect"); + color: Theme.text-primary; + font-size: 14px; + font-weight: 600; + vertical-alignment: center; + horizontal-stretch: 1; + } + } + Rectangle { + height: 1px; + background: Theme.border-subtle; + } + HorizontalLayout { + spacing: 8px; + VerticalLayout { + alignment: center; + Rectangle { + width: 8px; + height: 8px; + border-radius: 4px; + background: NowPlayingState.qconnect-connected ? #22c55e : Theme.text-muted; + } + } + Text { + text: NowPlayingState.qconnect-connected + ? @tr("Connected") + : @tr("Disconnected"); + color: Theme.text-secondary; + font-size: 12px; + vertical-alignment: center; + horizontal-stretch: 1; + } + } + if NowPlayingState.is-remote && NowPlayingState.cast-target != "": Text { + text: @tr("Playing on: {}", NowPlayingState.cast-target); + color: Theme.accent; + font-size: 11px; + overflow: elide; + } + Rectangle { + vertical-stretch: 1; + background: Theme.surface-elevated; + border-radius: Radius.sm; + clip: true; + if QconnectDevState.devices.length == 0: VerticalLayout { + alignment: center; + spacing: 4px; + Text { + text: @tr("No devices found"); + color: Theme.text-secondary; + font-size: 12px; + horizontal-alignment: center; + } + Text { + text: @tr("Make sure your renderer is on the same network"); + color: Theme.text-muted; + font-size: 10px; + horizontal-alignment: center; + wrap: word-wrap; + } + } + if QconnectDevState.devices.length > 0: Flickable { + viewport-height: dev-rows.preferred-height; + dev-rows := VerticalLayout { + padding: 4px; + spacing: 2px; + for d in QconnectDevState.devices: Rectangle { + height: 34px; + border-radius: Radius.sm; + background: row-ta.has-hover ? Theme.surface-hover : transparent; + row-ta := TouchArea { + clicked => { + QconnectDevState.set-active(d.renderer-id); + qconnect-menu.close(); + } + } + HorizontalLayout { + padding-left: 8px; + padding-right: 8px; + spacing: 8px; + VerticalLayout { + alignment: center; + QbzIcon { + source: d.icon == "mobile" + ? @image-url("../assets/icons/smartphone.svg") + : d.icon == "speaker" + ? @image-url("../assets/icons/speaker.svg") + : d.icon == "web" + ? @image-url("../assets/icons/globe.svg") + : @image-url("../assets/icons/monitor.svg"); + width: 14px; + height: 14px; + tint: d.is-active ? Theme.accent : Theme.text-secondary; + } + } + Text { + text: d.is-local ? @tr("Play here") : d.name; + color: d.is-active ? Theme.text-primary : Theme.text-secondary; + font-size: 12px; + font-weight: d.is-active ? 600 : 400; + vertical-alignment: center; + horizontal-stretch: 1; + overflow: elide; + } + VerticalLayout { + alignment: center; + Rectangle { + width: 8px; + height: 8px; + border-radius: 4px; + background: d.is-active ? Theme.accent : transparent; + } + } + } + } + } + } + } + Rectangle { + height: 34px; + border-radius: Radius.sm; + background: connect-ta.pressed + ? Theme.accent-pressed + : connect-ta.has-hover ? Theme.accent-hover : Theme.accent; + connect-ta := TouchArea { + clicked => { + NowPlayingState.qconnect-toggle(); + qconnect-menu.close(); + } + } + Text { + text: NowPlayingState.qconnect-connected + ? @tr("Disconnect") + : @tr("Connect"); + color: Theme.accent-text; + font-size: 13px; + font-weight: 600; + horizontal-alignment: center; + vertical-alignment: center; + } + } + } + } + } + } + } + + // Cast (Chromecast / DLNA) — opens the cast flyout. Mirrors + // PlayerBar's cast button + popup verbatim (NOT a dead stub; + // the popup is the same placeholder New ships today). + VerticalLayout { + alignment: center; + Rectangle { + width: 32px; + height: 32px; + IconButton { + icon: @image-url("../assets/icons/cast.svg"); + icon-size: 16px; + btn-width: 32px; + tooltip: @tr("Cast"); + active: NowPlayingState.cast-active; + clicked => { + cast-menu.show(); + } + } + cast-menu := PopupWindow { + // Inner Rectangle FILLS the popup, so the visible + // bottom == y + height. Homologated to -7 (flush + // just above the 3px seekbar; bar top ≈ -6.5). + x: 32px - 280px; + y: -251px; + width: 280px; + height: 244px; + close-policy: close-on-click-outside; + Rectangle { + background: Theme.surface-main; + border-radius: Radius.sm; + border-width: 1px; + border-color: Theme.border-muted; + drop-shadow-blur: 22px; + drop-shadow-color: Theme.card-shadow; + drop-shadow-offset-y: 6px; + VerticalLayout { + padding: 14px; + spacing: 12px; + HorizontalLayout { + spacing: 8px; + QbzIcon { + source: @image-url("../assets/icons/cast.svg"); + width: 16px; + height: 16px; + tint: Theme.text-primary; + } + Text { + text: @tr("Cast"); + color: Theme.text-primary; + font-size: 14px; + font-weight: 600; + vertical-alignment: center; + horizontal-stretch: 1; + } + } + Rectangle { + height: 1px; + background: Theme.border-subtle; + } + HorizontalLayout { + spacing: 8px; + VerticalLayout { + alignment: center; + Rectangle { + width: 8px; + height: 8px; + border-radius: 4px; + background: NowPlayingState.cast-active ? #a855f7 : Theme.text-muted; + } + } + Text { + text: NowPlayingState.cast-active + ? @tr("Casting") + : @tr("Not casting"); + color: Theme.text-secondary; + font-size: 12px; + vertical-alignment: center; + horizontal-stretch: 1; + } + } + Rectangle { + vertical-stretch: 1; + background: Theme.surface-elevated; + border-radius: Radius.sm; + VerticalLayout { + alignment: center; + spacing: 4px; + Text { + text: @tr("No cast devices found"); + color: Theme.text-secondary; + font-size: 12px; + horizontal-alignment: center; + } + Text { + text: @tr("Looking for Chromecast & DLNA on your network"); + color: Theme.text-muted; + font-size: 10px; + horizontal-alignment: center; + wrap: word-wrap; + } + } + } + } + } + } + } + } + + // Lyrics — toggles the lyrics panel (1:1 with PlayerBar:765). + VerticalLayout { + alignment: center; + IconButton { + icon: @image-url("../assets/icons/mic-vocal.svg"); + icon-size: 16px; + btn-width: 32px; + tooltip: @tr("Lyrics"); + active: ShellState.lyrics-open; + clicked => { + ShellState.lyrics-open = !ShellState.lyrics-open; + } + } + } + + // Settings — the SAME audio-menu flyout as New/Classic + // (Normalization + Gapless), a popup not a single toggle. + VerticalLayout { + alignment: center; + Rectangle { + width: 32px; + height: 32px; + IconButton { + icon: @image-url("../assets/icons/settings-2.svg"); + icon-size: 16px; + btn-width: 32px; + tooltip: @tr("Audio settings"); + // Neutral always: this button opens a flyout, so its + // colour should NOT reflect a toggle (normalization). + active: false; + clicked => { + audio-menu.show(); + } + } + audio-menu := PopupWindow { + // Anchored just above the button (bottom ~-8) at + // its NATURAL height — the two toggle rows only, NO + // inflated envelope/header (owner: the homologation + // is the Y anchor, not the size; keep it short like + // it was). ToggleRow is file-private to PlayerBar, + // so the rows are built inline with QbzToggle. + // Inner Rectangle FILLS the popup, so the visible + // bottom == y + height. Reference flyout: nudged + // 1px DOWN (-126 -> -125) so the bottom lands at + // -7, flush just above the 3px seekbar (bar top + // edge ≈ -6.5) — matching cast/qconnect/layout. + x: 32px - 252px; + // Pushed down ~8px vs the computed -125 so it + // renders biting the seekbar like cast/qconnect/ + // layout (same computed bottom rendered higher for + // this short popup — homologated empirically). + y: -117px; + width: 252px; + height: 118px; + close-policy: close-on-click-outside; + Rectangle { + background: Theme.surface-main; + border-radius: Radius.sm; + border-width: 1px; + border-color: Theme.border-muted; + drop-shadow-blur: 22px; + drop-shadow-color: Theme.card-shadow; + drop-shadow-offset-y: 6px; + VerticalLayout { + padding: 8px; + spacing: 4px; + HorizontalLayout { + height: 44px; + spacing: 12px; + VerticalLayout { + alignment: center; + horizontal-stretch: 1; + spacing: 1px; + Text { + text: @tr("Normalization"); + color: Theme.text-primary; + font-size: 13px; + } + Text { + text: @tr("Level loudness across tracks"); + color: Theme.text-muted; + font-size: 10px; + } + } + VerticalLayout { + alignment: center; + QbzToggle { + checked: SettingsState.normalization; + toggled(v) => { + root.settings-bool("normalization", v); + } + } + } + } + HorizontalLayout { + height: 44px; + spacing: 12px; + VerticalLayout { + alignment: center; + horizontal-stretch: 1; + spacing: 1px; + Text { + text: @tr("Gapless"); + color: Theme.text-primary; + font-size: 13px; + } + Text { + text: @tr("Seamless track transitions"); + color: Theme.text-muted; + font-size: 10px; + } + } + VerticalLayout { + alignment: center; + QbzToggle { + checked: SettingsState.gapless; + toggled(v) => { + root.settings-bool("gapless", v); + } + } + } + } + } + } + } + } + } + + Rectangle { width: 4px; } + + // Volume — mute icon + (WIDE) inline horizontal slider / + // (NARROW) a button opening a vertical slider flyout. Both + // respect vol-locked (dim 0.5 + no-op). + VerticalLayout { + alignment: center; + opacity: root.vol-locked ? 0.5 : 1.0; + IconButton { + icon: NowPlayingState.muted + ? @image-url("../assets/icons/volume-x.svg") + : @image-url("../assets/icons/volume-2.svg"); + icon-size: 16px; + btn-width: 32px; + // Wide = the button mutes (Mute/Unmute); narrow = it + // OPENS the vertical volume flyout, so it's "Volume" + // (the mute glyph lives at the flyout's foot). + tooltip: root.volume-wide + ? (NowPlayingState.muted ? @tr("Unmute") : @tr("Mute")) + : @tr("Volume"); + active: NowPlayingState.muted; + clicked => { + if (!root.vol-locked) { + if (root.volume-wide) { + NowPlayingState.toggle-mute(); + } else { + // Narrow: the button surfaces the vertical + // slider; the mute glyph lives at its foot. + vol-flyout.show(); + } + } + } + } + // Narrow vertical-slider flyout, popping UP over the button. + // Homologated to the cast flyout: TOP at -252px, bottom at + // -8px (h244). It is a narrow 32px column, so rather than + // float a short slider in the middle, the slider is grown to + // fill the taller envelope and the mute button stays pinned + // to the FOOT (near the button) — content sensibly placed. + vol-flyout := PopupWindow { + x: 0px; + y: -252px; + width: 32px; + height: 244px; + close-policy: close-on-click-outside; + Rectangle { + background: Theme.surface-main; + border-radius: Radius.sm; + border-width: 1px; + border-color: Theme.border-muted; + drop-shadow-blur: 18px; + drop-shadow-color: Theme.card-shadow; + drop-shadow-offset-y: 4px; + VerticalLayout { + padding: 8px; + spacing: 6px; + alignment: center; + HorizontalLayout { + alignment: center; + QbzVerticalSlider { + // Grown from 96px so the slider fills the + // homologated 244px envelope instead of + // leaving dead space above it. + height: 190px; + minimum: 0; + maximum: 100; + value: NowPlayingState.volume * 100; + changed(v) => { + if (!root.vol-locked) { + NowPlayingState.set-volume(v / 100.0); + } + } + } + } + HorizontalLayout { + alignment: center; + IconButton { + icon: NowPlayingState.muted + ? @image-url("../assets/icons/volume-x.svg") + : @image-url("../assets/icons/volume-2.svg"); + icon-size: 15px; + btn-width: 28px; + tooltip: NowPlayingState.muted ? @tr("Unmute") : @tr("Mute"); + active: NowPlayingState.muted; + clicked => { + if (!root.vol-locked) { + NowPlayingState.toggle-mute(); + } + } + } + } + } + } + } + } + // Wide: inline horizontal slider beside the mute icon. + if root.volume-wide: VerticalLayout { + alignment: center; + opacity: root.vol-locked ? 0.5 : 1.0; + QbzSlider { + width: 80px; + minimum: 0; + maximum: 100; + value: NowPlayingState.volume * 100; + changed(v) => { + if (!root.vol-locked) { + NowPlayingState.set-volume(v / 100.0); + } + } + } + } + + Rectangle { width: 4px; } + + // Queue panel toggle — same ShellState.queue-open flip as New. + VerticalLayout { + alignment: center; + IconButton { + icon: @image-url("../assets/icons/list-ordered.svg"); + icon-size: 16px; + btn-width: 32px; + tooltip: @tr("Queue"); + active: ShellState.queue-open; + clicked => { + ShellState.queue-open = !ShellState.queue-open; + } + } + } + } + } + } + } +} diff --git a/crates/qbz-slint/ui/shell/SeekBar.slint b/crates/qbz-slint/ui/shell/SeekBar.slint index da7184b3e..d2983d8d2 100644 --- a/crates/qbz-slint/ui/shell/SeekBar.slint +++ b/crates/qbz-slint/ui/shell/SeekBar.slint @@ -13,9 +13,13 @@ export component SeekBar inherits HorizontalLayout { in property elapsed: "0:00"; in property remaining: "0:00"; in property 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 show-times: true; callback seek(float); // 0..1 - spacing: 12px; + spacing: root.show-times ? 12px : 0px; function clamp01(v: float) -> float { return Math.min(Math.max(v, 0.0), 1.0); @@ -24,7 +28,7 @@ export component SeekBar inherits HorizontalLayout { return "\{Math.floor(secs / 60)}:\{Math.mod(secs, 60) < 10 ? "0" : ""}\{Math.mod(secs, 60)}"; } - VerticalLayout { + if root.show-times: VerticalLayout { alignment: center; Text { text: root.elapsed; @@ -132,7 +136,7 @@ export component SeekBar inherits HorizontalLayout { } } - VerticalLayout { + if root.show-times: VerticalLayout { alignment: center; Text { text: root.remaining; diff --git a/crates/qbz-slint/ui/shell/SongCard.slint b/crates/qbz-slint/ui/shell/SongCard.slint index 322d7a1b0..886e0e145 100644 --- a/crates/qbz-slint/ui/shell/SongCard.slint +++ b/crates/qbz-slint/ui/shell/SongCard.slint @@ -12,7 +12,7 @@ import { Typography } from "../foundation/typography.slint"; import { QbzIcon } from "../primitives/QbzIcon.slint"; import { QualityBadgeFull } from "../primitives/QualityBadgeFull.slint"; import { LoadingSpinner } from "../primitives/LoadingSpinner.slint"; -import { NowPlayingState, SettingsState, TooltipState } from "../state.slint"; +import { NowPlayingState, SettingsState, TooltipState, ArtPreviewState } from "../state.slint"; // Clickable artist/album link. Elides and shares the row width through a // stretch factor (the artist gets the larger share) so neither can be pushed @@ -43,7 +43,7 @@ component MetaLink inherits TouchArea { height: 100%; text: root.label; color: root.has-hover ? Theme.text-primary : Theme.text-muted; - font-size: 12px; + font-size: 11px; overflow: elide; vertical-alignment: center; } @@ -102,6 +102,26 @@ export component SongCard inherits Rectangle { in property art-size: 60px; in property show-art: true; in property show-badges: true; + // Optional border around the cover art. Defaults OFF (0px / transparent) so + // every existing call site (New/Classic SongCard) is UNAFFECTED; the Small + // bar passes a 2px subtle border so the flush-left art reads as defined. + in property art-border-width: 0px; + in property art-border-color: transparent; + // Title font size. Defaults to Typography.body (15px) so every existing + // call site is unchanged; the Small bar passes a smaller value (12px) so + // the compact card's title drops ~1-2pt under the New/Classic card. + in property title-font-size: Typography.body; + // Gap between the album art and the title/meta column. The Small bar + // tightens it by 2px; default keeps New/Classic unchanged. + in property art-text-gap: 11px; + // When true, the title+artist text block is constrained to the art image's + // inner height (art-size minus the border) and vertically CENTRED as a + // tight group, so the title's top lines up with the art image top and the + // artist's bottom with the art image bottom — instead of the title sticking + // to the row top and the artist to the row bottom. Defaults OFF so New/ + // Classic SongCards keep their current full-height, space-distributed + // layout. The Small bar sets this true. + in property text-center: false; // Below the responsive break the stamp shrinks 10% (proportional) so it // keeps clear of the controls column; above the break it is full size. in property narrow: false; @@ -175,6 +195,8 @@ export component SongCard inherits Rectangle { width: root.art-size; height: root.art-size; border-radius: 6px; + border-width: root.art-border-width; + border-color: root.art-border-color; background: Theme.surface-elevated; clip: true; @@ -229,11 +251,32 @@ export component SongCard inherits Rectangle { y: Math.round((parent.height - self.height) / 2 / 1px) * 1px; } } + + // Hover preview: while the pointer is over the cover, a 220x220 + // high-res preview floats ABOVE it (1:1 Tauri). Rendered by the + // global ArtPreviewOverlay (mounted last in AppShell) — NOT a + // PopupWindow: that stole the hover (the trigger's has-hover flipped + // when the popup showed), causing show/close flicker. This top-most + // TouchArea only reports the anchor + visibility (the overlay reads + // the cover from NowPlayingState). Coexists with the cover Image / + // idle cat / spinner above (none have a TouchArea), consumes no + // clicks elsewhere; gated on has-track so it never opens when idle. + art-hover-ta := TouchArea { + changed has-hover => { + if (self.has-hover && NowPlayingState.has-track) { + ArtPreviewState.anchor-x = self.absolute-position.x + self.width / 2; + ArtPreviewState.anchor-y = self.absolute-position.y; + ArtPreviewState.show = true; + } else if (!self.has-hover) { + ArtPreviewState.show = false; + } + } + } } } // Fixed gap: cover -> song info. - if root.show-art: Rectangle { width: 11px; } + if root.show-art: Rectangle { width: root.art-text-gap; } // --- Title + context/artist/album + renderer badge ------------------- VerticalLayout { @@ -243,19 +286,138 @@ export component SongCard inherits Rectangle { min-width: 0px; alignment: center; spacing: 4px; + // When text-center is on (Small bar), an inner fixed-height wrapper + // (= art image inner height) holds the title+meta as a TIGHT centred + // group, so the title top aligns with the art image top and the artist + // bottom with the art image bottom. The outer column keeps its existing + // full-row stretch + alignment:center, so New/Classic are untouched and + // this just centres a shorter inner block. The wrapper is transparent + // (pure layout) when on; off, this child is zero and the title/meta + // below render directly in the column (current behaviour). + if root.text-center: VerticalLayout { + height: root.art-size - 2 * root.art-border-width; + // Tight line-height: the box is only ~31px (art inner height), so the + // title (13px) + meta line need a small inter-line gap or the 2nd line + // (artist·album) clips at the bottom. 1px keeps both lines comfortably + // inside without shrinking the fonts. + spacing: 1px; + alignment: center; + Rectangle { + tc-title := Text { + width: 100%; + text: NowPlayingState.has-track + ? NowPlayingState.title + : @tr("Nothing playing"); + color: Theme.text-primary; + font-size: root.title-font-size; + font-weight: Typography.medium; + overflow: elide; + } + tc-ta := TouchArea { + mouse-cursor: (NowPlayingState.has-track && !NowPlayingState.is-ephemeral) + ? pointer : default; + clicked => { + if (NowPlayingState.has-track && !NowPlayingState.is-ephemeral) { + root.track-info(); + } + } + changed has-hover => { + if (self.has-hover && NowPlayingState.has-track + && tc-title.preferred-width > self.width) { + TooltipState.text = NowPlayingState.title; + TooltipState.anchor-x = tc-ta.absolute-position.x + tc-ta.width / 2; + TooltipState.anchor-y = tc-ta.absolute-position.y; + TooltipState.show = true; + } else if (!self.has-hover) { + TooltipState.show = false; + } + } + } + } + if NowPlayingState.has-track: HorizontalLayout { + spacing: 7px; + if SettingsState.show-context-icon: Rectangle { + width: 16px; + height: 18px; + border-radius: 3px; + background: tcctx-ta.has-hover ? Theme.surface-hover : transparent; + QbzIcon { + source: @image-url("../assets/icons/layers.svg"); + width: 13px; + height: 13px; + x: 0; + y: Math.round((parent.height - self.height) / 2 / 1px) * 1px; + tint: tcctx-ta.has-hover ? Theme.text-primary : Theme.text-muted; + } + tcctx-ta := TouchArea { + mouse-cursor: pointer; + clicked => { + if (root.ctx-id != "") { + root.open-context(root.ctx-kind, root.ctx-id); + } + } + changed has-hover => { + if (self.has-hover) { + TooltipState.text = @tr("Go to where this is playing from"); + TooltipState.anchor-x = parent.absolute-position.x + parent.width / 2; + TooltipState.anchor-y = parent.absolute-position.y; + TooltipState.show = true; + } else { + TooltipState.show = false; + } + } + } + } + MetaLink { + label: NowPlayingState.artist; + stretch: 2.0; + activated => { + if (!NowPlayingState.is-ephemeral) { + if (NowPlayingState.artist-id != "") { + root.open-artist(NowPlayingState.artist-id); + } else if (NowPlayingState.artist != "") { + root.open-artist(NowPlayingState.artist); + } + } + } + } + VerticalLayout { + alignment: center; + Rectangle { + width: 3px; + height: 3px; + border-radius: 1.5px; + background: Theme.text-muted; + } + } + MetaLink { + label: NowPlayingState.album; + stretch: 1.0; + activated => { + if (NowPlayingState.album-id != "" && !NowPlayingState.is-ephemeral) { + root.open-album(NowPlayingState.album-id); + } + } + } + } + } // Title — elides, and on hover shows the full text in a tooltip ONLY // when it is actually truncated (the audio stamp ate into it). // Title — elides. Clicking it opens track info (the transport's (i) // is the second trigger, 1:1 with Tauri's title-click). Hovering a // truncated title shows the full text in a tooltip. - Rectangle { + // DEFAULT layout (text-center OFF): the title + meta render directly in + // the column (full-row stretch + alignment:center). New/Classic use + // this path unchanged. The text-center path above (Small bar) is the + // tight inner-block alternative. + if !root.text-center: Rectangle { title-txt := Text { width: 100%; text: NowPlayingState.has-track ? NowPlayingState.title : @tr("Nothing playing"); color: Theme.text-primary; - font-size: Typography.body; + font-size: root.title-font-size; font-weight: Typography.medium; overflow: elide; } @@ -281,7 +443,7 @@ export component SongCard inherits Rectangle { } } } - if NowPlayingState.has-track: HorizontalLayout { + if !root.text-center && NowPlayingState.has-track: HorizontalLayout { spacing: 7px; // Context (layers) button — opens the page playback came from. @@ -291,11 +453,10 @@ export component SongCard inherits Rectangle { border-radius: 3px; background: ctxta.has-hover ? Theme.surface-hover : transparent; QbzIcon { - // turntable (the "playing from" context), pinned flush-LEFT - // (x:0): centering the glyph in its box left a ~2px indent so - // the artist·album line read as misaligned vs the title. - // (disc-album now means "flat folders" in the Folders toggle.) - source: @image-url("../assets/icons/turntable.svg"); + // layers (the "playing from" context, 1:1 with Tauri), pinned + // flush-LEFT (x:0): centering the glyph in its box left a ~2px + // indent so the artist·album line read as misaligned vs the title. + source: @image-url("../assets/icons/layers.svg"); width: 13px; height: 13px; x: 0; diff --git a/crates/qbz-slint/ui/state.slint b/crates/qbz-slint/ui/state.slint index 129fa14f2..ee64fb0d9 100644 --- a/crates/qbz-slint/ui/state.slint +++ b/crates/qbz-slint/ui/state.slint @@ -2845,6 +2845,11 @@ export global NowPlayingState { in property album-id; in property artist-id; in property artwork; + // Higher-res cover (~300px) for the hover preview that floats above the + // now-playing bar's small art, so the ~220px popup is crisp instead of an + // upscale of the 160px bar art. Loaded alongside `artwork`; cleared on + // track change. Falls back to `artwork` in the UI until it resolves. + in property artwork-large; in property track-id; // True when the playing track is from an ephemeral folder (synthetic id): // it has no DB row, so favorite / add-to-playlist / track-info are gated off. @@ -2875,6 +2880,15 @@ export global NowPlayingState { in property quality-tier; // "hires" | "cd" | "mp3" | "" in property quality-detail; // "24-bit / 96 kHz" + // Output backend + mode LEDs (Mode C "Small" bar reads these). Mirror of + // the same four on SettingsState (:2154-2157) — surfaced here so the + // Small now-playing bar has ONE source for the song card + DAC/EXC + // cluster. Pushed on every audio snapshot-apply (src/settings.rs). + in property output-backend-label: "SYST"; // PIPE|ALSA|JACK|PULS|SYST + in property output-mode-label: "DEFAULT"; // DACPASS|BITPERF|EXCL|DIRECT|LOCKED|ROUTED|SHARED|DEFAULT + in property output-backend-active: false; + in property output-mode-active: false; + // Cast / render-aware state (Qobuz Connect). `is-remote` = a peer // renderer owns playback (controls route to it); `volume-locked` = // the active renderer disallows remote volume control. Both default @@ -3046,6 +3060,17 @@ export global TooltipState { in-out property show: false; } +// Floating album-art preview (now-playing cover hover). Overlay-rendered like +// the tooltip so it NEVER steals hover from the trigger — a PopupWindow DID, +// which flipped the trigger's has-hover and made the preview flicker. The +// overlay reads the cover straight from NowPlayingState; this only carries the +// anchor + visibility. +export global ArtPreviewState { + in-out property anchor-x; // art centre, window coords + in-out property anchor-y; // art top, window coords + in-out property show: false; +} + // Playback queue model, for the Queue sidebar. // // The sidebar shows two tabs. The Queue tab renders `now-playing` plus a