feat(slint): immersive track info inline panel (split)
Add ImmersiveTrackInfoPanel for the split-right slot (split-panel 1): title + album, Duration/Quality/ISRC/Label-link metadata rows, grouped credits and copyright, reusing MetaCell/CreditCell from TrackInfoModal (now exported). A new load-without-open path (info_modals:: load_track_info_inline via TrackInfoActions.load-inline) populates TrackInfoState without raising the floating modal, so the inline panel fills in place; the data refreshes on now-playing track change. Header gains a Track Info tab in the split rail (Lyrics, Track Info, Queue). cc
This commit is contained in:
6 files changed
+342
-11
No files matched your search
@@ -434,20 +434,26 @@ fn apply_album_credits(window: &AppWindow, data: AlbumCreditsData) {
|
||||
// Public spawn entry points (called from the media-action handler).
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Fetch a track and open the Track Info modal.
|
||||
pub fn open_track_info<A>(
|
||||
/// Shared fetch+map+apply for Track Info. `open_modal` decides whether the
|
||||
/// floating modal is shown: `true` for the explicit (i)-button flow, `false`
|
||||
/// for the immersive split panel which renders the same data inline (and so
|
||||
/// must NOT pop the overlay over the immersive view).
|
||||
fn spawn_track_info<A>(
|
||||
runtime: Arc<AppRuntime<A>>,
|
||||
weak: slint::Weak<AppWindow>,
|
||||
handle: tokio::runtime::Handle,
|
||||
track_id: u64,
|
||||
open_modal: bool,
|
||||
) where
|
||||
A: FrontendAdapter + Send + Sync + 'static,
|
||||
{
|
||||
let _ = weak.upgrade_in_event_loop(|w| {
|
||||
let _ = weak.upgrade_in_event_loop(move |w| {
|
||||
let st = w.global::<TrackInfoState>();
|
||||
st.set_error("".into());
|
||||
st.set_loading(true);
|
||||
st.set_open(true);
|
||||
if open_modal {
|
||||
st.set_open(true);
|
||||
}
|
||||
});
|
||||
handle.spawn(async move {
|
||||
match runtime.core().get_track(track_id).await {
|
||||
@@ -471,6 +477,34 @@ pub fn open_track_info<A>(
|
||||
});
|
||||
}
|
||||
|
||||
/// Fetch a track and open the Track Info modal.
|
||||
pub fn open_track_info<A>(
|
||||
runtime: Arc<AppRuntime<A>>,
|
||||
weak: slint::Weak<AppWindow>,
|
||||
handle: tokio::runtime::Handle,
|
||||
track_id: u64,
|
||||
) where
|
||||
A: FrontendAdapter + Send + Sync + 'static,
|
||||
{
|
||||
spawn_track_info(runtime, weak, handle, track_id, true);
|
||||
}
|
||||
|
||||
/// Fetch a track and populate TrackInfoState WITHOUT opening the modal — for
|
||||
/// the immersive split Track Info panel (data-panels.md §7), which renders the
|
||||
/// metadata + grouped credits + copyright inline. Same fetch+map+apply as
|
||||
/// `open_track_info`; `open` stays false so the floating modal never appears
|
||||
/// over the immersive overlay.
|
||||
pub fn load_track_info_inline<A>(
|
||||
runtime: Arc<AppRuntime<A>>,
|
||||
weak: slint::Weak<AppWindow>,
|
||||
handle: tokio::runtime::Handle,
|
||||
track_id: u64,
|
||||
) where
|
||||
A: FrontendAdapter + Send + Sync + 'static,
|
||||
{
|
||||
spawn_track_info(runtime, weak, handle, track_id, false);
|
||||
}
|
||||
|
||||
/// Fetch an album and open the Album Info (Credits/Review) modal.
|
||||
pub fn open_album_credits<A>(
|
||||
runtime: Arc<AppRuntime<A>>,
|
||||
|
||||
@@ -7862,6 +7862,23 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.invoke_musician_clicked(name, role);
|
||||
}
|
||||
});
|
||||
// Immersive split Track Info panel: populate TrackInfoState for the
|
||||
// given track WITHOUT opening the floating modal (open stays false).
|
||||
let weak = window.as_weak();
|
||||
let runtime_l = runtime.clone();
|
||||
let handle_l = tokio_rt.handle().clone();
|
||||
window
|
||||
.global::<TrackInfoActions>()
|
||||
.on_load_inline(move |track_id| {
|
||||
if let Ok(id) = track_id.parse::<u64>() {
|
||||
info_modals::load_track_info_inline(
|
||||
runtime_l.clone(),
|
||||
weak.clone(),
|
||||
handle_l.clone(),
|
||||
id,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// -- Album Info --
|
||||
let weak = window.as_weak();
|
||||
|
||||
@@ -13,7 +13,8 @@ import { QbzIcon } from "../primitives/QbzIcon.slint";
|
||||
import { ListScrollbar } from "../primitives/ListScrollbar.slint";
|
||||
|
||||
// One metadata cell: uppercase label (11px) + a value supplied as a child.
|
||||
component MetaCell inherits VerticalLayout {
|
||||
// Exported so the immersive split Track Info panel can reuse it 1:1.
|
||||
export component MetaCell inherits VerticalLayout {
|
||||
in property <string> label;
|
||||
spacing: 6px;
|
||||
Text {
|
||||
@@ -29,7 +30,8 @@ component MetaCell inherits VerticalLayout {
|
||||
// One credit cell: role label (11px upper) + the performer names, each
|
||||
// clickable -> musician. Clipped so a long name list can't bleed into the
|
||||
// neighbouring column (the common 1-3 name case fits one line).
|
||||
component CreditCell inherits VerticalLayout {
|
||||
// Exported so the immersive split Track Info panel can reuse it 1:1.
|
||||
export component CreditCell inherits VerticalLayout {
|
||||
in property <InfoCreditRow> cell;
|
||||
callback name-clicked(string /* name */, string /* role-raw */);
|
||||
spacing: 6px;
|
||||
|
||||
@@ -0,0 +1,234 @@
|
||||
// Immersive split Track Info panel — the INLINE credits panel mounted in the
|
||||
// SPLIT-right slot (ImmersiveState.split-panel == 1). 1:1 with Tauri's
|
||||
// TrackInfoPanel.svelte (recon data-panels.md §7): track title + album, the
|
||||
// Duration / Quality / ISRC / Label(link) metadata rows, the grouped CREDITS
|
||||
// section, and the copyright line. Split-only (no focus variant).
|
||||
//
|
||||
// Data is fed by crate::info_modals::load_track_info_inline via
|
||||
// TrackInfoActions.load-inline — it populates the SAME TrackInfoState the
|
||||
// floating modal reads, but never sets `open`, so the overlay modal does NOT
|
||||
// appear over the immersive view. The shared metadata/credit cells are reused
|
||||
// 1:1 from TrackInfoModal.slint (MetaCell / CreditCell).
|
||||
//
|
||||
// Rendered white-on-dark over the atmosphere backdrop (vs the modal's
|
||||
// surface-card), matching the other immersive split panels. Viewport dims are
|
||||
// passed as props (no `parent` in the root binding); no `opacity:` on the
|
||||
// root; no `changed` watcher on layout geometry (ADR-009 declaration order,
|
||||
// reference_slint_* gotchas).
|
||||
|
||||
import { TrackInfoState, TrackInfoActions } from "../state.slint";
|
||||
import { MetaCell, CreditCell } from "../album/TrackInfoModal.slint";
|
||||
import { ListScrollbar } from "../primitives/ListScrollbar.slint";
|
||||
|
||||
export component ImmersiveTrackInfoPanel inherits Rectangle {
|
||||
// Slot dimensions, supplied by the mount site (the split-right Rectangle).
|
||||
in property <length> viewport-width: 480px;
|
||||
in property <length> viewport-height: 600px;
|
||||
// When true (split placement) the content is height-capped + vertically
|
||||
// centered in the slot, mirroring Tauri's `centeredLayout`.
|
||||
in property <bool> centered: true;
|
||||
|
||||
width: root.viewport-width;
|
||||
height: root.viewport-height;
|
||||
background: transparent;
|
||||
|
||||
// Centered, height-capped content column (Tauri .centered-layout:
|
||||
// height clamp(340px, 62vh, 760px); max-height 80vh).
|
||||
VerticalLayout {
|
||||
alignment: root.centered ? center : start;
|
||||
Rectangle {
|
||||
height: root.centered
|
||||
? Math.min(root.viewport-height,
|
||||
Math.clamp(340px, root.viewport-height * 0.62, 760px))
|
||||
: root.viewport-height;
|
||||
|
||||
// ---- Loading -----------------------------------------------
|
||||
if TrackInfoState.loading && TrackInfoState.error == "": Text {
|
||||
text: @tr("Loading track info...");
|
||||
color: #ffffff80;
|
||||
font-size: 18px;
|
||||
horizontal-alignment: center;
|
||||
vertical-alignment: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
// ---- Error -------------------------------------------------
|
||||
if TrackInfoState.error != "": VerticalLayout {
|
||||
alignment: center;
|
||||
spacing: 8px;
|
||||
Text {
|
||||
text: @tr("Failed to load track info");
|
||||
color: #ffffff80;
|
||||
font-size: 18px;
|
||||
horizontal-alignment: center;
|
||||
}
|
||||
Text {
|
||||
text: TrackInfoState.error;
|
||||
color: #ffffff66;
|
||||
font-size: 13px;
|
||||
horizontal-alignment: center;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Empty (no track / not yet loaded) ---------------------
|
||||
if !TrackInfoState.loading && TrackInfoState.error == "" && TrackInfoState.title == "": Text {
|
||||
text: @tr("No track selected");
|
||||
color: #ffffff66;
|
||||
font-size: 18px;
|
||||
horizontal-alignment: center;
|
||||
vertical-alignment: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
// ---- Loaded ------------------------------------------------
|
||||
if !TrackInfoState.loading && TrackInfoState.error == "" && TrackInfoState.title != "": Rectangle {
|
||||
clip: true;
|
||||
|
||||
flick := Flickable {
|
||||
viewport-width: self.width;
|
||||
viewport-height: body.preferred-height;
|
||||
|
||||
body := VerticalLayout {
|
||||
width: parent.width;
|
||||
padding-right: 12px;
|
||||
|
||||
// Header: track title + album.
|
||||
VerticalLayout {
|
||||
spacing: 4px;
|
||||
padding-bottom: 24px;
|
||||
Text {
|
||||
text: TrackInfoState.title;
|
||||
color: #ffffff;
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
if TrackInfoState.album != "": Text {
|
||||
text: TrackInfoState.album;
|
||||
color: #ffffff99;
|
||||
font-size: 18px;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
}
|
||||
|
||||
// Metadata rows: Duration, Quality, ISRC, Label(link).
|
||||
VerticalLayout {
|
||||
spacing: 24px;
|
||||
HorizontalLayout {
|
||||
spacing: 24px;
|
||||
MetaCell {
|
||||
horizontal-stretch: 1;
|
||||
label: @tr("Duration");
|
||||
Text {
|
||||
text: TrackInfoState.duration;
|
||||
color: #ffffff;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
MetaCell {
|
||||
horizontal-stretch: 1;
|
||||
label: @tr("Quality");
|
||||
Text {
|
||||
text: TrackInfoState.quality;
|
||||
color: #ffffff;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
if TrackInfoState.isrc != "": MetaCell {
|
||||
horizontal-stretch: 1;
|
||||
label: "ISRC";
|
||||
Text {
|
||||
text: TrackInfoState.isrc;
|
||||
color: #ffffffb3;
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
if TrackInfoState.isrc == "": Rectangle { horizontal-stretch: 1; }
|
||||
}
|
||||
if TrackInfoState.label != "": HorizontalLayout {
|
||||
spacing: 24px;
|
||||
MetaCell {
|
||||
horizontal-stretch: 1;
|
||||
label: @tr("Label");
|
||||
label-link := TouchArea {
|
||||
width: label-text.preferred-width;
|
||||
height: label-text.preferred-height;
|
||||
mouse-cursor: TrackInfoState.label-id != "" ? pointer : default;
|
||||
clicked => {
|
||||
if (TrackInfoState.label-id != "") {
|
||||
TrackInfoActions.open-label(TrackInfoState.label-id);
|
||||
}
|
||||
}
|
||||
label-text := Text {
|
||||
text: TrackInfoState.label;
|
||||
color: (label-link.has-hover && TrackInfoState.label-id != "")
|
||||
? #b794f6 : #ffffff;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
}
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
}
|
||||
}
|
||||
|
||||
// Grouped CREDITS (2-column), only when present.
|
||||
if TrackInfoState.credits.length > 0: Rectangle { height: 20px; }
|
||||
if TrackInfoState.credits.length > 0: Rectangle {
|
||||
height: 1px;
|
||||
background: #ffffff1a;
|
||||
}
|
||||
if TrackInfoState.credits.length > 0: Rectangle { height: 20px; }
|
||||
if TrackInfoState.credits.length > 0: VerticalLayout {
|
||||
spacing: 16px;
|
||||
for pair in TrackInfoState.credits: HorizontalLayout {
|
||||
spacing: 24px;
|
||||
CreditCell {
|
||||
horizontal-stretch: 1;
|
||||
cell: pair.left;
|
||||
name-clicked(n, r) => {
|
||||
TrackInfoActions.open-musician(n, r);
|
||||
}
|
||||
}
|
||||
if pair.has-right: CreditCell {
|
||||
horizontal-stretch: 1;
|
||||
cell: pair.right;
|
||||
name-clicked(n, r) => {
|
||||
TrackInfoActions.open-musician(n, r);
|
||||
}
|
||||
}
|
||||
if !pair.has-right: Rectangle { horizontal-stretch: 1; }
|
||||
}
|
||||
}
|
||||
|
||||
// Copyright.
|
||||
if TrackInfoState.copyright != "": Rectangle { height: 20px; }
|
||||
if TrackInfoState.copyright != "": Rectangle {
|
||||
height: 1px;
|
||||
background: #ffffff1a;
|
||||
}
|
||||
if TrackInfoState.copyright != "": Rectangle { height: 20px; }
|
||||
if TrackInfoState.copyright != "": Text {
|
||||
text: TrackInfoState.copyright;
|
||||
color: #ffffff66;
|
||||
font-size: 12px;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ListScrollbar {
|
||||
x: parent.width - self.width;
|
||||
width: 14px;
|
||||
height: 100%;
|
||||
viewport-height: flick.viewport-height;
|
||||
visible-height: flick.height;
|
||||
viewport-y <=> flick.viewport-y;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import { Radius } from "../foundation/radius.slint";
|
||||
import { QbzIcon } from "../primitives/QbzIcon.slint";
|
||||
import { NowPlayingState, VisualizerState, ImmersiveState, SettingsState, LyricsState, QueueState } from "../state.slint";
|
||||
import { NowPlayingState, VisualizerState, ImmersiveState, SettingsState, LyricsState, QueueState, TrackInfoActions } from "../state.slint";
|
||||
import { ImmersiveAtmosphere } from "ImmersiveAtmosphere.slint";
|
||||
import { AlbumReactivePanel } from "AlbumReactivePanel.slint";
|
||||
import { StaticPanel } from "StaticPanel.slint";
|
||||
@@ -13,6 +13,7 @@ import { SpectrumPanel } from "SpectrumPanel.slint";
|
||||
import { ImmersiveLyricsFocusPanel } from "ImmersiveLyricsFocusPanel.slint";
|
||||
import { ImmersiveQueuePanel } from "ImmersiveQueuePanel.slint";
|
||||
import { ImmersiveTrackInfo } from "ImmersiveTrackInfo.slint";
|
||||
import { ImmersiveTrackInfoPanel } from "ImmersiveTrackInfoPanel.slint";
|
||||
import { LyricsLinesView } from "../shell/LyricsLinesView.slint";
|
||||
|
||||
component GhostButton inherits Rectangle {
|
||||
@@ -491,6 +492,9 @@ component ModeBar inherits Rectangle {
|
||||
// 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();
|
||||
// Fired when the user enters the split Track Info panel so the parent can
|
||||
// kick the inline load for the current track (TrackInfoActions.load-inline).
|
||||
callback trackinfo-entered();
|
||||
|
||||
property <bool> is-split: ImmersiveState.view-mode == 1;
|
||||
|
||||
@@ -597,8 +601,8 @@ component ModeBar inherits Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
// SPLIT rail: Lyrics (Checkpoint A) + Queue (Checkpoint B). Track Info /
|
||||
// Suggestions tabs land in their own checkpoints.
|
||||
// SPLIT rail: Lyrics (Checkpoint A) + Track Info (Checkpoint C) +
|
||||
// Queue (Checkpoint B). Suggestions tab lands in its own checkpoint.
|
||||
if root.is-split: HorizontalLayout {
|
||||
spacing: 4px;
|
||||
ModeTab {
|
||||
@@ -610,6 +614,15 @@ component ModeBar inherits Rectangle {
|
||||
root.lyrics-entered();
|
||||
}
|
||||
}
|
||||
ModeTab {
|
||||
icon: @image-url("../assets/icons/info.svg");
|
||||
label: @tr("Track Info");
|
||||
active: ImmersiveState.split-panel == 1;
|
||||
clicked => {
|
||||
root.select-split(1);
|
||||
root.trackinfo-entered();
|
||||
}
|
||||
}
|
||||
ModeTab {
|
||||
icon: @image-url("../assets/icons/list-music.svg");
|
||||
label: @tr("Queue");
|
||||
@@ -855,6 +868,23 @@ export component ImmersiveView inherits Rectangle {
|
||||
// Solid white active line in immersive (data-panels.md §2).
|
||||
active-color: #ffffff;
|
||||
}
|
||||
// Checkpoint C: the inline Track Info credits panel, centered in
|
||||
// the right half (split-only, data-panels §7). `init` populates
|
||||
// TrackInfoState for the current track WITHOUT opening the modal
|
||||
// (TrackInfoActions.load-inline -> open stays false). A
|
||||
// `changed NowPlayingState.track-id` guard re-fires the load so the
|
||||
// panel refreshes when the track changes while it's open (track-id
|
||||
// is a string — safe to watch, no layout geometry involved).
|
||||
if ImmersiveState.split-panel == 1: ImmersiveTrackInfoPanel {
|
||||
property <string> live-track-id: NowPlayingState.track-id;
|
||||
init => { TrackInfoActions.load-inline(NowPlayingState.track-id); }
|
||||
changed live-track-id => { TrackInfoActions.load-inline(self.live-track-id); }
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
viewport-width: parent.width;
|
||||
viewport-height: parent.height;
|
||||
centered: true;
|
||||
}
|
||||
// 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).
|
||||
@@ -898,11 +928,16 @@ export component ImmersiveView inherits Rectangle {
|
||||
}
|
||||
toggle-view => {
|
||||
ImmersiveState.view-mode = ImmersiveState.view-mode == 1 ? 0 : 1;
|
||||
// Entering split lands on Lyrics (the only Checkpoint A panel) —
|
||||
// kick the fetch so the doc loads immediately.
|
||||
// Entering split kicks the load for whichever panel is already
|
||||
// selected so it populates immediately (the panel's own `init`
|
||||
// covers the first mount; this handles re-entry onto an existing
|
||||
// selection).
|
||||
if (ImmersiveState.view-mode == 1 && ImmersiveState.split-panel == 0) {
|
||||
LyricsState.panel-opened();
|
||||
}
|
||||
if (ImmersiveState.view-mode == 1 && ImmersiveState.split-panel == 1) {
|
||||
TrackInfoActions.load-inline(NowPlayingState.track-id);
|
||||
}
|
||||
root.wake();
|
||||
}
|
||||
lyrics-entered => {
|
||||
@@ -913,5 +948,9 @@ export component ImmersiveView inherits Rectangle {
|
||||
QueueState.panel-opened();
|
||||
root.wake();
|
||||
}
|
||||
trackinfo-entered => {
|
||||
TrackInfoActions.load-inline(NowPlayingState.track-id);
|
||||
root.wake();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -532,6 +532,11 @@ export global TrackInfoActions {
|
||||
callback open-artist(string /* artist-id */);
|
||||
callback open-label(string /* label-id */);
|
||||
callback open-musician(string /* name */, string /* role */);
|
||||
// Populate TrackInfoState for the given track WITHOUT opening the floating
|
||||
// modal — used by the immersive split Track Info panel, which renders the
|
||||
// same data inline. Fetch+map+apply are identical to open-track-info; the
|
||||
// ONLY difference is `open` stays false so the overlay modal never appears.
|
||||
callback load-inline(string /* track-id */);
|
||||
}
|
||||
|
||||
// Album Info modal — opened from the AlbumPageView header (i) button via
|
||||
|
||||
Reference in new issue
Block a user