From 55fc6fa13f532b7d03c3ac4fa0f085fa3deb1290 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Fri, 19 Jun 2026 05:54:58 -0600 Subject: [PATCH] feat(slint): immersive queue panel (focus + split) with queue/history tabs Add ImmersiveQueuePanel, one component used both as a focus full-screen queue (mode 5) and the split-right panel (split-panel 3). Queue/History sub-tabs bound to QueueState.tab/set-tab; NOW PLAYING card + UP NEXT list from the flat coverflow-tracks model (upcoming index = idx - coverflow-index - 1 -> play-coverflow-upcoming), History from the canonical history list. Header gains a Queue tab in both rails; QueueState.panel-opened() fires on entry. Rows reuse the queue row shape; scrolling via Flickable + shared ListScrollbar. cc --- .../ui/immersive/ImmersiveQueuePanel.slint | 437 ++++++++++++++++++ .../ui/immersive/ImmersiveView.slint | 56 ++- crates/qbz-slint/ui/state.slint | 5 +- 3 files changed, 493 insertions(+), 5 deletions(-) create mode 100644 crates/qbz-slint/ui/immersive/ImmersiveQueuePanel.slint diff --git a/crates/qbz-slint/ui/immersive/ImmersiveQueuePanel.slint b/crates/qbz-slint/ui/immersive/ImmersiveQueuePanel.slint new file mode 100644 index 000000000..fb18341a5 --- /dev/null +++ b/crates/qbz-slint/ui/immersive/ImmersiveQueuePanel.slint @@ -0,0 +1,437 @@ +// Immersive Queue panel (Checkpoint B) — ONE component used in BOTH the +// focus full-screen placement (ImmersiveState.mode == 5) and the split centered +// placement (ImmersiveState.split-panel == 3), mirroring Tauri's single +// QueuePanel.svelte (data-panels.md §4 Queue + §5 History). +// +// Two sub-tabs ("Queue" / "History") bound to QueueState.tab via +// QueueState.set-tab(...). The Queue tab shows a highlighted NOW PLAYING card +// plus a scrolling UP NEXT list of the upcoming entries; the History tab shows +// the most-recent-first history list. Rows reuse QueueSidebar's QueueRow visual +// structure (40x40-ish cover, title/artist, duration, hover-reveal play button). +// Playback logic is NOT duplicated — rows only fire QueueState callbacks. +// +// SLINT GOTCHAS honored: +// - viewport dims are passed in as props; `parent` is NEVER read in the root +// binding (Slint recursion trap). +// - `opacity:` is NEVER set on the root (it corrupts absolute positioning); +// inner content is dimmed instead. Chrome fade lives on the parent. +// - no `changed`-watching of layout geometry; no z-index (declaration order is +// the stacking order, ADR-009). +// - scrolling uses Flickable + the shared ListScrollbar idiom (codebase +// convention, see MiniQueueSurface) — NOT a bare native ScrollView. + +import { NowPlayingState, QueueState, QueueItem } from "../state.slint"; +import { ListScrollbar } from "../primitives/ListScrollbar.slint"; +import { QbzIcon } from "../primitives/QbzIcon.slint"; + +// Explicit "E" badge — immersive (white-on-glass) variant of the queue badge. +component ImmExplicitBadge inherits Rectangle { + width: 16px; + height: 16px; + border-radius: 3px; + background: #ffffff1f; + Text { + text: "E"; + color: #ffffffa6; + font-size: 9px; + font-weight: 600; + horizontal-alignment: center; + vertical-alignment: center; + x: 0; y: 0; + width: parent.width; + height: parent.height; + } +} + +// One Queue / History sub-tab — plain text, NO pill (ADR-008). Mirrors the +// QueueSidebar QueueTab brightness idiom, recolored white-on-glass for the +// immersive backdrop. +component SubTab inherits Rectangle { + in property label; + in property count: 0; + in property active: false; + callback clicked(); + + height: 32px; + border-radius: 8px; + background: root.active ? #ffffff26 : (ta.has-hover ? #ffffff14 : transparent); + animate background { duration: 150ms; } + + HorizontalLayout { + padding-left: 12px; + padding-right: 12px; + spacing: 6px; + alignment: center; + Text { + text: root.label; + color: root.active ? #ffffff : (ta.has-hover ? #ffffffd9 : #ffffff99); + font-size: 17px; + font-weight: root.active ? 600 : 500; + vertical-alignment: center; + animate color { duration: 150ms; } + } + if root.count > 0: Text { + text: "(" + root.count + ")"; + color: #ffffff66; + font-size: 15px; + vertical-alignment: center; + } + } + + ta := TouchArea { + mouse-cursor: pointer; + clicked => { root.clicked(); } + } +} + +// One UP NEXT / History row. 40x40 cover, title/artist, duration, and a +// hover-revealed circular play button. Fires `play()` on click OR play-button — +// the parent maps it to the right QueueState callback. Reuses QueueRow's visual +// structure (data-panels.md §4 `.track-item` 40px art + ellipsis title). +component ImmQueueRow inherits Rectangle { + in property item; + in property current: false; // NOW PLAYING highlight + callback play(); + + height: 56px; + border-radius: 8px; + // `.track-item.current` (data-panels §4): --alpha-10 bg + 1px --alpha-15 + // border. Plain rows: transparent, hover --alpha-10. + background: root.current + ? #ffffff1a + : (ta.has-hover ? #ffffff1a : transparent); + border-width: root.current ? 1px : 0px; + border-color: #ffffff26; + animate background { duration: 150ms; } + + ta := TouchArea { + mouse-cursor: pointer; + clicked => { root.play(); } + } + + HorizontalLayout { + padding-left: 8px; + padding-right: 8px; + spacing: 10px; + + // 40x40 cover. + VerticalLayout { + alignment: center; + Rectangle { + width: 40px; + height: 40px; + border-radius: 4px; + background: #ffffff14; + clip: true; + if root.item.artwork.width > 0: Image { + source: root.item.artwork; + width: 100%; + height: 100%; + image-fit: cover; + } + } + } + + // Title + artist. + VerticalLayout { + horizontal-stretch: 1; + alignment: center; + spacing: 2px; + HorizontalLayout { + spacing: 5px; + Text { + text: root.item.title; + color: #ffffff; + font-size: 17px; + font-weight: 500; + overflow: elide; + } + if root.item.explicit: VerticalLayout { + alignment: center; + ImmExplicitBadge {} + } + } + Text { + text: root.item.artist; + color: #ffffff99; + font-size: 16px; + overflow: elide; + } + } + + // Duration. + VerticalLayout { + alignment: center; + Text { + text: root.item.duration; + color: #ffffff80; + font-size: 16px; + } + } + + // Hover-revealed circular play button (28px). Hidden for the current + // (now-playing) row, which is not re-playable. + VerticalLayout { + alignment: center; + width: 32px; + if !root.current: play-btn := Rectangle { + width: 28px; + height: 28px; + border-radius: 14px; + background: pta.has-hover ? #ffffff40 : #ffffff26; + opacity: ta.has-hover || pta.has-hover ? 1.0 : 0.0; + animate opacity { duration: 150ms; } + QbzIcon { + source: @image-url("../assets/icons/play-fill.svg"); + width: 13px; + height: 13px; + x: Math.round((parent.width - self.width) / 2 / 1px) * 1px + 1px; + y: Math.round((parent.height - self.height) / 2 / 1px) * 1px; + tint: #ffffff; + } + pta := TouchArea { + mouse-cursor: pointer; + clicked => { root.play(); } + } + } + } + } +} + +export component ImmersiveQueuePanel inherits Rectangle { + in property viewport-width: 1280px; + in property viewport-height: 720px; + // true in the split (centered) placement, false in focus full-screen. + in property centered: false; + + background: transparent; + + // Content width: in focus full-screen we cap to a comfortable reading + // column and center it; in split we already live in the right half, so we + // fill it. (data-panels §4 `.centered-layout` width:100%.) + property content-width: root.centered + ? root.viewport-width + : Math.min(root.viewport-width - 96px, 720px); + + // The upcoming entries are the slice of `coverflow-tracks` AFTER the + // now-playing index. Their COUNT (page/search-independent) drives the tab + // badge + section header. Floored at 0. + property upcoming-count: + Math.max(0, QueueState.coverflow-tracks.length - QueueState.coverflow-index - 1); + + // Centered content column. + HorizontalLayout { + alignment: center; + VerticalLayout { + width: root.content-width; + padding-top: 56px; // clear the top ModeBar chrome + padding-bottom: 132px; // clear the floating player chrome + padding-left: root.centered ? 0px : 8px; + padding-right: root.centered ? 0px : 8px; + spacing: 16px; + + // --- Sub-tab header (Queue / History) --------------------------- + HorizontalLayout { + spacing: 8px; + alignment: start; + SubTab { + label: @tr("Queue"); + count: root.upcoming-count; + active: QueueState.tab == 0; + clicked => { QueueState.set-tab(0); } + } + SubTab { + label: @tr("History"); + count: QueueState.history.length; + active: QueueState.tab == 1; + clicked => { QueueState.set-tab(1); } + } + Rectangle { horizontal-stretch: 1; } + // Clear-queue button — Queue tab only, when there is something + // upcoming (data-panels §4 `.clear-btn`). + if QueueState.tab == 0 && root.upcoming-count > 0: VerticalLayout { + alignment: center; + clear-btn := Rectangle { + height: 30px; + border-radius: 8px; + background: cta.has-hover ? #ffffff26 : #ffffff14; + animate background { duration: 150ms; } + HorizontalLayout { + padding-left: 12px; + padding-right: 12px; + spacing: 6px; + alignment: center; + QbzIcon { + source: @image-url("../assets/icons/trash-2.svg"); + width: 14px; + height: 14px; + tint: #ffffffcc; + } + Text { + text: @tr("Clear"); + color: #ffffffcc; + font-size: 16px; + vertical-alignment: center; + } + } + cta := TouchArea { + mouse-cursor: pointer; + clicked => { QueueState.clear-queue(); } + } + } + } + } + // Header underline (data-panels §4 `.panel-header` border-bottom). + Rectangle { + height: 1px; + background: #ffffff1a; + } + + // --- Body ------------------------------------------------------- + Rectangle { + vertical-stretch: 1; + + // ===== QUEUE tab ===== + if QueueState.tab == 0: Rectangle { + // NOW PLAYING card + UP NEXT list, OR empty state. + if QueueState.has-current || root.upcoming-count > 0: VerticalLayout { + spacing: 12px; + + // NOW PLAYING section. + if QueueState.has-current: VerticalLayout { + spacing: 8px; + Text { + text: @tr("NOW PLAYING"); + color: #ffffff80; + font-size: 15px; + font-weight: 600; + letter-spacing: 0.5px; + } + ImmQueueRow { + item: QueueState.now-playing; + current: true; + } + } + + // UP NEXT section. + if root.upcoming-count > 0: VerticalLayout { + vertical-stretch: 1; + spacing: 8px; + Text { + text: @tr("UP NEXT"); + color: #ffffff80; + font-size: 15px; + font-weight: 600; + letter-spacing: 0.5px; + } + Rectangle { + vertical-stretch: 1; + up-flick := Flickable { + width: 100%; + height: 100%; + viewport-width: self.width; + viewport-height: up-list.preferred-height; + up-list := VerticalLayout { + width: parent.width; + // spacing 0 — the inter-row gap is baked + // into each VISIBLE wrapper's height (60 = + // 56 row + 4 gap), with the row anchored to + // the bottom. History entries (idx <= + // coverflow-index) collapse to 0px AND + // contribute no spacing, so a long history + // adds NO phantom top space. + spacing: 0px; + // Iterate the flat whole-queue model and + // render only the entries AFTER the + // now-playing index. Flat index `idx` + // maps to the queue-wide upcoming index + // `idx - coverflow-index - 1` + // (data-panels §4 actualIndex math; see + // QueueState.play-coverflow-upcoming). + for item[idx] in QueueState.coverflow-tracks: Rectangle { + height: idx > QueueState.coverflow-index ? 60px : 0px; + if idx > QueueState.coverflow-index: ImmQueueRow { + x: 0; + y: parent.height - self.height; + width: parent.width; + height: 56px; + item: item; + play => { + QueueState.play-coverflow-upcoming( + idx - QueueState.coverflow-index - 1); + } + } + } + } + } + ListScrollbar { + x: parent.width - self.width; + y: 0; + height: parent.height; + viewport-height: up-flick.viewport-height; + visible-height: up-flick.height; + viewport-y <=> up-flick.viewport-y; + auto-hide: true; + } + } + } + } + + // Empty state — nothing playing and nothing upcoming. + if !QueueState.has-current && root.upcoming-count == 0: VerticalLayout { + alignment: center; + Text { + text: @tr("Your queue is empty"); + color: #ffffff66; + font-size: 18px; + font-italic: true; + horizontal-alignment: center; + } + } + } + + // ===== HISTORY tab ===== + if QueueState.tab == 1: Rectangle { + if QueueState.history.length > 0: Rectangle { + hist-flick := Flickable { + width: 100%; + height: 100%; + viewport-width: self.width; + viewport-height: hist-list.preferred-height; + hist-list := VerticalLayout { + width: parent.width; + spacing: 4px; + // QueueState.history is already most-recent-first + // (matches QueueSidebar), and play-history(idx) + // indexes it directly — no coverflow math here. + for item[idx] in QueueState.history: ImmQueueRow { + item: item; + play => { QueueState.play-history(idx); } + } + } + } + ListScrollbar { + x: parent.width - self.width; + y: 0; + height: parent.height; + viewport-height: hist-flick.viewport-height; + visible-height: hist-flick.height; + viewport-y <=> hist-flick.viewport-y; + auto-hide: true; + } + } + if QueueState.history.length == 0: VerticalLayout { + alignment: center; + Text { + text: @tr("Nothing played yet"); + color: #ffffff66; + font-size: 18px; + font-italic: true; + horizontal-alignment: center; + } + } + } + } + } + } +} diff --git a/crates/qbz-slint/ui/immersive/ImmersiveView.slint b/crates/qbz-slint/ui/immersive/ImmersiveView.slint index 22352b291..3e3acbe59 100644 --- a/crates/qbz-slint/ui/immersive/ImmersiveView.slint +++ b/crates/qbz-slint/ui/immersive/ImmersiveView.slint @@ -4,13 +4,14 @@ import { Radius } from "../foundation/radius.slint"; import { QbzIcon } from "../primitives/QbzIcon.slint"; -import { NowPlayingState, VisualizerState, ImmersiveState, SettingsState, LyricsState } from "../state.slint"; +import { NowPlayingState, VisualizerState, ImmersiveState, SettingsState, LyricsState, QueueState } from "../state.slint"; import { ImmersiveAtmosphere } from "ImmersiveAtmosphere.slint"; import { AlbumReactivePanel } from "AlbumReactivePanel.slint"; import { StaticPanel } from "StaticPanel.slint"; import { CoverflowPanel } from "CoverflowPanel.slint"; import { SpectrumPanel } from "SpectrumPanel.slint"; import { ImmersiveLyricsFocusPanel } from "ImmersiveLyricsFocusPanel.slint"; +import { ImmersiveQueuePanel } from "ImmersiveQueuePanel.slint"; import { ImmersiveTrackInfo } from "ImmersiveTrackInfo.slint"; import { LyricsLinesView } from "../shell/LyricsLinesView.slint"; @@ -487,6 +488,9 @@ component ModeBar inherits Rectangle { // Fired whenever the user enters a lyrics surface (focus Lyrics tab or // split Lyrics panel) so the parent can kick LyricsState.panel-opened(). callback lyrics-entered(); + // Fired whenever the user enters a queue surface (focus Queue tab or split + // Queue panel) so the parent can kick QueueState.panel-opened(). + callback queue-entered(); property is-split: ImmersiveState.view-mode == 1; @@ -582,10 +586,19 @@ component ModeBar inherits Rectangle { root.lyrics-entered(); } } + ModeTab { + icon: @image-url("../assets/icons/list-music.svg"); + label: @tr("Queue"); + active: ImmersiveState.mode == 5; + clicked => { + root.select(5); + root.queue-entered(); + } + } } - // SPLIT rail: only Lyrics for Checkpoint A (Track Info / Suggestions / - // Queue tabs land in their own checkpoints). + // SPLIT rail: Lyrics (Checkpoint A) + Queue (Checkpoint B). Track Info / + // Suggestions tabs land in their own checkpoints. if root.is-split: HorizontalLayout { spacing: 4px; ModeTab { @@ -597,6 +610,15 @@ component ModeBar inherits Rectangle { root.lyrics-entered(); } } + ModeTab { + icon: @image-url("../assets/icons/list-music.svg"); + label: @tr("Queue"); + active: ImmersiveState.split-panel == 3; + clicked => { + root.select-split(3); + root.queue-entered(); + } + } } } } @@ -737,6 +759,19 @@ export component ImmersiveView inherits Rectangle { viewport-width: root.width; viewport-height: root.height; } + // (2f) Queue-focus foreground (mode == 5) — the SAME ImmersiveQueuePanel as + // the split placement, full-screen (centered: false). Queue + History + // sub-tabs. `init` pulls a fresh queue snapshot (mirror of the sidebar's + // init -> panel-opened()). Same conditional-mount + viewport-prop contract + // as the siblings (ADR-010). + if ImmersiveState.shader-mode == 0 && ImmersiveState.view-mode == 0 && ImmersiveState.mode == 5: ImmersiveQueuePanel { + init => { QueueState.panel-opened(); } + x: 0px; + y: 0px; + viewport-width: root.width; + viewport-height: root.height; + centered: false; + } // (2-split) SPLIT layout (view-mode == 1): artwork + metadata LEFT, the // active data panel RIGHT (ADR-010 conditional mount). The atmosphere stays @@ -820,6 +855,17 @@ export component ImmersiveView inherits Rectangle { // Solid white active line in immersive (data-panels.md §2). active-color: #ffffff; } + // Checkpoint B: the Queue + History panel, centered in the right + // half. Same component as the focus mount; `centered: true` fills + // the slot (data-panels §4 — one QueuePanel in both placements). + if ImmersiveState.split-panel == 3: ImmersiveQueuePanel { + init => { QueueState.panel-opened(); } + width: 100%; + height: 100%; + viewport-width: parent.width; + viewport-height: parent.height; + centered: true; + } } } @@ -863,5 +909,9 @@ export component ImmersiveView inherits Rectangle { LyricsState.panel-opened(); root.wake(); } + queue-entered => { + QueueState.panel-opened(); + root.wake(); + } } } diff --git a/crates/qbz-slint/ui/state.slint b/crates/qbz-slint/ui/state.slint index 89ce983bb..44f2f0afb 100644 --- a/crates/qbz-slint/ui/state.slint +++ b/crates/qbz-slint/ui/state.slint @@ -3218,8 +3218,9 @@ export global ImmersiveState { // FOCUS-mode foreground for the conditional-mounted panel (read only while // view-mode == 0): // 0 = Album Reactive, 1 = Static, 2 = Coverflow, 3 = Spectrum, - // 4 = Lyrics-focus (one giant centered current line). - // (5 = Queue-focus is reserved for a later checkpoint — NOT added yet.) + // 4 = Lyrics-focus (one giant centered current line), + // 5 = Queue-focus (full-screen Queue + History panel; reuses QueueState, + // no extra state field — same component as the split Queue panel). // SESSION default 0 (Album Reactive) so opening shows a real foreground. // NOTE: this compact enum is a Slint-scaffold contract; it deliberately // does NOT match Tauri's focus-tab string order (coverflow first). Product